In my .toml
file I define a feature turned off by default:
[features]
foo = []
If this feature is enabled I want to print "FOO":
fn main() {
#[cfg(feature = "foo")]
println!("FOO");
}
I can then compile (and run) the code like this: cargo run --features foo
However, I'd prefer to use the shorthand that I see in the docs. Something like this:
fn main() {
#[cfg(foo)]
println!("FOO");
}
However, when using the same cargo run
command as earlier the print statement doesn't compile. What am I missing?