I\'m wondering if something like this is possible
fn main() {
#[cfg(foo)] {
println!(\"using foo config\");
}
}
The context is
You may interested in the crate cfg-if, or a simple macro will do:
macro_rules! conditional_compile {
($(#[$ATTR:meta])* { $CODE: tt }) => {
{
match 0 {
$(#[$ATTR])*
0 => $CODE,
// suppress clippy warnning `single_match`.
1 => (),
_ => (),
}
}
}
}
fn main() {
conditional_compile{
#[cfg(foo)]
{{
println!("using foo config");
// Or something only exists in cfg foo, like a featured mod.
}}
}
}