1 2 3 4 5 6 7 8 9 10
use std::sync::atomic::*; static NEXT_ID: AtomicUsize = AtomicUsize::new(1); /// Create a non-zero ID that is unique to this process. /// /// Suitable for image IDs and placement IDs. pub fn unique_id() -> usize { NEXT_ID.fetch_add(1, Ordering::SeqCst) }