Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. use lazy_static::lazy_static; // 1.3.0
  2.  
  3. use std::sync::atomic::{Ordering, AtomicBool};
  4.  
  5. static VERBOSE: AtomicBool = AtomicBool::new(false);
  6.  
  7. fn log_or_not(value: &str) {
  8. if VERBOSE.load(Ordering::SeqCst) {
  9. println!("{}", value);
  10. }
  11. }
  12.  
  13. fn main() {
  14. log_or_not("foo");
  15.  
  16. VERBOSE.store(true, Ordering::SeqCst);
  17.  
  18. log_or_not("bar");
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement