SHARE
TWEET

Untitled

a guest Sep 18th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top