std::cfg! [] [src]

macro_rules! cfg {
    ($($cfg:tt)*) => { ... };
}
1.0.0

Boolean evaluation of configuration flags.

In addition to the #[cfg] attribute, this macro is provided to allow boolean expression evaluation of configuration flags. This frequently leads to less duplicated code.

The syntax given to this macro is the same syntax as the cfg attribute.

Examples

fn main() { let my_directory = if cfg!(windows) { "windows-specific-directory" } else { "unix-directory" }; }
let my_directory = if cfg!(windows) {
    "windows-specific-directory"
} else {
    "unix-directory"
};