1 2 3 4 5 6 7 8 9 10 11 12 13 14
pub type Id = u32; #[derive(Default)] pub struct IdGenerator { next: Id, } impl IdGenerator { pub fn next_id(&mut self) -> Id { let out = self.next; self.next += 1; out } }