cfg-if icon indicating copy to clipboard operation
cfg-if copied to clipboard

Allow to have multiple conditions in the same macro call

Open GuillaumeGomez opened this issue 1 year ago • 2 comments

It's quite convenient when you have multiple small conditions and want coherency across cfg handling (example with sysinfo crate):

cfg_if::cfg_if! {
    if #[cfg(feature = "system")] {
        if #[cfg(not(feature = "apple-sandbox"))] {
            pub(crate) mod cpu;
            pub mod system;
            pub mod process;
        } else {
            pub use crate::sys::app_store::process;
        }
    }

    if #[cfg(feature = "disk")] {
        pub mod disk;
    }

    if #[cfg(feature = "apple-sandbox")] {
        pub use crate::sys::app_store::component;
    } else {
        pub mod component;
    }
}

GuillaumeGomez avatar Jun 24 '24 19:06 GuillaumeGomez