usestd::sync::{Arc, Mutex};// We used a mutex instead of an atomic because in benchmarks it seems to be
// faster, and we can explicitly enforce u64 even on 32-bit systems (as of the
// time of this writing, `AtomicUsize` is stable but `AtomicU64` is not)
#[derive(Clone, Debug)]pubstructCounter(Arc<Mutex<u64>>);implCounter{pubfnnew()->Self{
Counter {0:Arc::new(Mutex::new(0)),}}pubfnincrement(&self){*self.0.lock().unwrap()+=1;}pubfndecrement(&self){*self.0.lock().unwrap()-=1;}pubfnget(&self)->u64{*self.0.lock().unwrap()}}