nscfg 1.0.0

Nifty Simple CFG provides a revamped syntax and macros to easily manage all #[cfg] parameters in one package. Compatible with stable toolchain and no dependencies. See README / Homepage for more details.
Documentation
  • Coverage
  • 100%
    4 out of 4 items documented4 out of 4 items with examples
  • Size
  • Source code size: 69.24 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 453.44 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • NickelAngeStudio/nscfg
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • NickelAngeStudio

nscfg

Nifty Simple CFG provides a revamped syntax and macros to easily manage all #[cfg] parameters in one package. See features to get the full list of features like aliases, attributes, automatic dependency tag documentation and more.

Example

Transform this :

#[cfg(any(doc, any(target_os = "linux", target_os = "macos", target_os = "windows")))]
#[cfg_attr(docsrs, doc(cfg(any(target_os = "linux", target_os = "windows", target_os = "macos"))))]
pub mod desktop_mod;

#[cfg(any(doc, any(target_os = "linux", target_os = "macos", target_os = "windows")))]
#[cfg_attr(docsrs, doc(cfg(any(target_os = "linux", target_os = "windows", target_os = "macos"))))]
pub use desktop_mod::Struct as Struct;

#[cfg(any(doc, any(target_os = "ios", target_os = "android")))]
#[cfg_attr(docsrs, doc(cfg(any(target_os = "ios", target_os = "android"))))]
pub mod mobile_mod;

#[cfg(any(doc, any(target_os = "ios", target_os = "android")))]
#[cfg_attr(docsrs, doc(cfg(any(target_os = "ios", target_os = "android"))))]
pub use mobile_mod::Struct1 as Struct1;

#[cfg(any(doc, any(target_os = "ios", target_os = "android")))]
#[cfg_attr(docsrs, doc(cfg(any(target_os = "ios", target_os = "android"))))]
pub use mobile_mod::Struct2 as Struct2;

#[cfg(any(doc, any(target_os = "ios", target_os = "android")))]
#[cfg_attr(docsrs, doc(cfg(any(target_os = "ios", target_os = "android"))))]
pub fn mobile_only_fn() {}

Into this :

target_cfg!{
    desktop => {
        pub mod desktop_mod;
        pub use desktop_mod::Struct as Struct;
    },
    mobile => {
        pub mod mobile_mod;
        pub use mobile_mod::Struct1 as Struct1;
        pub use mobile_mod::Struct2 as Struct2;
        pub fn mobile_only_fn() {}
    }
}

See examples for more use cases.

Installation

Execute this command in your Rust project folder.

cargo add nscfg

Dependencies

nscfg has no dependencies and only use stable rust library.

Question?

See nscfg wiki, it contains a LOT of information.