use runestick::Id;
use std::cell::Cell;
use std::rc::Rc;
#[derive(Default, Debug, Clone)]
pub(crate) struct Gen {
id: Rc<Cell<Id>>,
}
impl Gen {
pub(crate) fn new() -> Self {
Self {
id: Rc::new(Cell::new(Id::initial())),
}
}
pub(crate) fn next(&self) -> Id {
let id = self.id.get();
let next = id.next().expect("ran out of ids");
self.id.set(next);
id
}
}