`cfg` which is always true / false?

Viewed 146

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?

1 Answers

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!");
}
Related