use cfg_match::*;
cfg_match! {
foo =>
fn item() -> bool { false }
any(bar, test) => {
fn item() -> bool { true }
}
_ => fn item() -> bool { false }
}
#[test]
fn smoke_test() {
assert!(item());
}
cfg_match! {
foo => fn f() -> bool { false }
_ => fn f() -> bool { true }
}
#[test]
fn fallback() {
assert!(f());
}
#[test]
fn expr() {
let f = cfg_match! {
foo => ({ false }),
test => ({
println!("whee");
true
}),
_ => false,
};
assert!(f);
}
#[test]
fn no_fallback() {
let f = cfg_match! {
foo => ({ false }),
test => ({
println!("whee");
true
}),
};
assert!(f);
}
cfg_match! {
#[cfg(foo)]
fn c() -> bool { false }
#[cfg('do)]
fn c2() -> bool { false }
#[cfg(_)]
fn c() -> bool { true }
#[cfg(_)]
fn c2() -> bool { true }
}
#[test]
fn cascade() {
assert!(c());
assert!(c2());
}