Macro mac::if_cfg [] [src]

macro_rules! if_cfg {
    ($cfg:meta $t:block else $f:block) => { ... };
    ($cfg:meta $t:block) => { ... };
}

Compile-time conditional expression.

Example

if_cfg!(test {
    println!("Crate built as a test suite");
})

Unlike if cfg!(...), this will not even compile the unused branch.

let x = if_cfg!(any(bleh, blah="bluh") {
    some_undefined_function_name();
    2 + "doesn't even typecheck"
} else {
    3
});

assert_eq!(x, 3);