1 2 3 4 5 6 7 8 9 10 11
use std::sync::atomic::{AtomicUsize, Ordering}; static NEXT_INTEGER: AtomicUsize = AtomicUsize::new(1); pub fn reset() { NEXT_INTEGER.store(1, Ordering::SeqCst); } pub fn next() -> usize { return NEXT_INTEGER.fetch_add(1, Ordering::SeqCst); }