1 #[cfg(feature = "static_keys_test")] 2 mod tests { 3 use static_keys::{define_static_key_false, static_branch_unlikely}; 4 define_static_key_false!(MY_STATIC_KEY); 5 #[inline(always)] 6 fn foo() { 7 println!("Entering foo function"); 8 if static_branch_unlikely!(MY_STATIC_KEY) { 9 println!("A branch"); 10 } else { 11 println!("B branch"); 12 } 13 } 14 15 pub(super) fn static_keys_test() { 16 foo(); 17 unsafe { 18 MY_STATIC_KEY.enable(); 19 } 20 foo(); 21 } 22 } 23 24 pub fn static_keys_init() { 25 static_keys::global_init(); 26 #[cfg(feature = "static_keys_test")] 27 tests::static_keys_test(); 28 } 29