I want rust code compiled when the compilation attribute debug_assertions is false (or not enabled), i.e. a "debug build".
Is this possible? What is the syntax?
For example, I can compile function build_type when compiling for debug build (i.e. option --release is not passed to command cargo build).
#[cfg(debug_assertions)]
pub fn build_type() -> String {
String::from("debug")
}
In this case, I want a "release version" of the function,
#[cfg(debug_assertions)]
pub fn build_type() -> String {
String::from("debug")
}
#[!cfg(debug_assertions)]
pub fn build_type() -> String {
String::from("release")
}
However, the syntax #[!cfg(debug_assertions)] results in cargo build error expected identifier, found '!'.
Other failed syntax variations were:
#[cfg(!debug_assertions)]#[cfg(debug_assertions = false)]#[cfg(debug_assertions = "false")]