floem/views/editor/id.rs
1use std::sync::atomic::AtomicU64;
2
3#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
4pub struct Id(u64);
5
6impl Id {
7 /// Allocate a new, unique `Id`.
8 pub fn next() -> Id {
9 static TIMER_COUNTER: AtomicU64 = AtomicU64::new(0);
10 Id(TIMER_COUNTER.fetch_add(1, std::sync::atomic::Ordering::Relaxed))
11 }
12
13 pub fn to_raw(self) -> u64 {
14 self.0
15 }
16}
17
18pub type EditorId = Id;