pub struct IdFactory<T>where
T: DenseId,{ /* private fields */ }Expand description
Sequential id allocator.
Implementations§
Source§impl<T> IdFactory<T>where
T: DenseId,
impl<T> IdFactory<T>where
T: DenseId,
pub fn new() -> IdFactory<T>
Sourcepub fn try_alloc(&mut self) -> Option<T>
pub fn try_alloc(&mut self) -> Option<T>
Allocate the next id: Some(id) with id.id_nat() == count while the
range lasts, None once count == id_bound (and usize can hold the
increment — the id bound is at most usize::MAX + 1, so next
saturating there means the range is done).
pub fn count(&self) -> usize
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for IdFactory<T>where
PhantomData<T>: Freeze,
impl<T> RefUnwindSafe for IdFactory<T>where
PhantomData<T>: RefUnwindSafe,
impl<T> Send for IdFactory<T>where
PhantomData<T>: Send,
impl<T> Sync for IdFactory<T>where
PhantomData<T>: Sync,
impl<T> Unpin for IdFactory<T>where
PhantomData<T>: Unpin,
impl<T> UnsafeUnpin for IdFactory<T>where
PhantomData<T>: UnsafeUnpin,
impl<T> UnwindSafe for IdFactory<T>where
PhantomData<T>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more