vertigo/css/next_id.rs
1use crate::computed::struct_mut::ValueMut;
2
3pub struct NextId {
4 counter: ValueMut<u64>,
5}
6
7impl NextId {
8 pub fn new() -> NextId {
9 NextId {
10 counter: ValueMut::new(0),
11 }
12 }
13
14 pub fn get_next_id(&self) -> u64 {
15 let current = self.counter.get() + 1;
16 self.counter.set(current);
17 current
18 }
19
20 #[cfg(test)]
21 pub fn current(&self) -> u64 {
22 self.counter.get()
23 }
24}