diff --git a/Cargo.toml b/Cargo.toml index f7ebd08..915ade5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,6 +55,7 @@ clap = "4.0.32" # Using features (aka conditional compilation with cfg) [features] foo = [] # feature has no explicit dependencies +aa = [] # feature has no explicit dependencies # Todo: how to use them? # Compile time env. vars diff --git a/src/cfg.rs b/src/cfg.rs index b0af195..504741f 100644 --- a/src/cfg.rs +++ b/src/cfg.rs @@ -13,6 +13,7 @@ const XX : i32 = 44; #[test] fn ex_1_should_fail_with_foo() { assert_eq!(XX, 44); } + // Using: if cfg!(feature = "foo") #[test] fn ex_2_using_if_cfg_and_should_fail_with_foo() { if cfg!(feature = "foo") { @@ -20,4 +21,11 @@ const XX : i32 = 44; } else { assert_eq!(42, 42); } +} + +// Will fail with +// cargo t cfg_all --features "foo aa" +#[test] fn ex_3_cfg_all() { + #[cfg(all(feature= "foo", feature= "aa"))] + assert_eq!(42, 43); } \ No newline at end of file