For testing purpose I need cfg which is always true / false.
For true I use
#[ cfg( target_pointer_width = "64") ]
...
But obviously it is not general enough.
What is optimal way of expressing cfg to get necessary value?
Just do this for a cfg option that is always true:
#[cfg(all())]
fn main() {
println!("It works!");
}
And if you need a cfg option that is always false you can use:
#[cfg(any())]
fn main() {
println!("It disappears!");
}
#[cfg(xxx)] to comment out some block of code, but this looks nicer, and can be changed from on to off just by overwriting two characters.
cfgdirective?any(foo, not(foo))is always true.#[cfg(any(foo, not(foo)))]will always evaluate