macro_rules! match_cfg { ( $( ($cfg:meta) => $e:expr, )* _ => $last:expr, ) => { ... }; ( $( ($cfg:meta) => $e:expr, )* ) => { ... }; }
Expand description
Compile-time matching on config variables.
Only the branch relevant on your machine will be type-checked!
ยงExample
let mascot = match_cfg! {
(target_os = "linux") => "penguin",
(target_os = "openbsd") => "blowfish",
_ => "unknown",
};
println!("{}", mascot);