[−][src]Macro match_cfg::match_cfg
The macro provided by this crate, match_cfg
, is similar to the if/elif
C
preprocessor directives and allows defining a cascade of #[cfg]
cases,
emitting the implementation which matches first.
This conveniently allows providing a long list #[cfg]
'd blocks of code
without having to rewrite each cfg()
clause multiple times.
Example
#[macro_use(match_cfg)] extern crate match_cfg; match_cfg! { #[cfg(unix)] => { fn foo() { /* unix specific functionality */ } } #[cfg(target_pointer_width = "32")] => { fn foo() { /* non-unix, 32-bit functionality */ } } _ => { fn foo() { /* fallback implementation */ } } }