1 2 3 4 5 6 7 8
pub struct UidGenerator; impl UidGenerator { pub fn generate() -> usize { static COUNTER: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); COUNTER.fetch_add(1, std::sync::atomic::Ordering::Relaxed) } }