#boost #match #meta #cfg #target

macro cfg_boost

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.

1 stable release

1.0.0 Apr 12, 2023

#2014 in Procedural macros

Download history 29/week @ 2025-04-20 28/week @ 2025-04-27 26/week @ 2025-05-04 46/week @ 2025-05-11 27/week @ 2025-05-18 29/week @ 2025-05-25 10/week @ 2025-06-01 16/week @ 2025-06-08 55/week @ 2025-06-15 46/week @ 2025-06-22 55/week @ 2025-06-29 28/week @ 2025-07-06 21/week @ 2025-07-13 6/week @ 2025-07-20 22/week @ 2025-07-27 23/week @ 2025-08-03

73 downloads per month

MIT license

65KB
831 lines

cfg_boost

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 cfg_boost

Dependencies

cfg_boost has no dependencies and only use stable rust library.

Question?

See cfg_boost wiki, it contains a LOT of information.

 

Sponsor me via GitHub Sponsors and get your sponsor royalty tier.

No runtime deps