Macro itron_solid_asp3::macros::match_kernel[][src]

pub macro match_kernel {
    (_ => { $($wildcard : tt) * }) => { ... },
    (_ => { $($wildcard : tt) * } $($rest : tt) *) => { ... },
    ($($kernel : tt) | + => { $($tt : tt) * } $($rest : tt) *) => { ... },
}
This is supported on crate features nightly and unstable only.
Expand description

Expand to the arm corresponding to the current kernel.

Example

itron::macros::match_kernel! {
    "asp3" | "solid_asp3" => { fn say() { println!("We are running on TOPPERS/ASP3, yay!"); } }
    "nonexistent_kernel" => { call_nonexistent_function(); }
    _ => { fn say() { println!("This kernel looks like something new!"); } }
}
say();

The arms don’t create local scopes, and unselected arms are eliminated during an early stage of compilation. Compare to the following example:

match itron::macros::kernel!() {
    "asp3" | "solid_asp3" => { fn say() { println!("We are running on TOPPERS/ASP3, yay!"); } }
    "nonexistent_kernel" => { call_nonexistent_function(); }
        // ERROR: `call_nonexistent_function` is undefined
    _ => { fn say() { println!("This kernel looks like something new!"); } }
}
say(); // ERROR: Each arm's `say` is not accessible from here