Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use lazy_static::lazy_static; // 1.3.0
- use std::sync::atomic::{Ordering, AtomicBool};
- static VERBOSE: AtomicBool = AtomicBool::new(false);
- fn log_or_not(value: &str) {
- if VERBOSE.load(Ordering::SeqCst) {
- println!("{}", value);
- }
- }
- fn main() {
- log_or_not("foo");
- VERBOSE.store(true, Ordering::SeqCst);
- log_or_not("bar");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement