pub macro cfg_match { ( $(cfg($initial_meta:meta) => { $($initial_tokens:tt)* })+ _ => { $($extra_tokens:tt)* } ) => { ... }, ($(cfg($extra_meta:meta) => { $($extra_tokens:tt)* })*) => { ... }, (@ __items($($_:meta,)*);) => { ... }, (@ __items($($no:meta,)*); (($($yes:meta)?) ($($tokens:tt)*)), $($rest:tt,)*) => { ... }, (@ __identity $($tokens:tt)*) => { ... }, }
🔬This is a nightly-only experimental API. (
cfg_match
#115585)Expand description
A macro for defining #[cfg]
match-like statements.
It is similar to the if/elif
C preprocessor macro by allowing definition of a cascade of
#[cfg]
cases, emitting the implementation which matches first.
This allows you to conveniently provide a long list #[cfg]
’d blocks of code
without having to rewrite each clause multiple times.
Trailing _
wildcard match arms are optional and they indicate a fallback branch when
all previous declarations do not evaluate to true.