[go: up one dir, main page]

cfg-if 0.1.9

A macro to ergonomically define an item depending on a large number of #[cfg] parameters. Structured like an if-else chain, the first matching branch is the item that gets emitted.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#[macro_use]
extern crate cfg_if;

cfg_if! {
    if #[cfg(foo)] {
        fn works() -> bool { false }
    } else if #[cfg(test)] {
        fn works() -> bool { true }
    } else {
        fn works() -> bool { false }
    }
}

#[test]
fn smoke() {
    assert!(works());
}