jump_label.rs 675 B

12345678910111213141516171819202122232425262728
  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. pub(super) fn static_keys_test() {
  15. foo();
  16. unsafe {
  17. MY_STATIC_KEY.enable();
  18. }
  19. foo();
  20. }
  21. }
  22. pub fn static_keys_init() {
  23. static_keys::global_init();
  24. #[cfg(feature = "static_keys_test")]
  25. tests::static_keys_test();
  26. }