pub struct Arena<K, T> { /* private fields */ }Expand description
A minimal generational arena (house rule: 40 boring lines beat a dependency). Slots are reused; each reuse bumps the generation.
Implementations§
Source§impl<K, T> Arena<K, T>
impl<K, T> Arena<K, T>
pub fn insert(&mut self, value: T) -> Id<K>
pub fn get_mut(&mut self, id: Id<K>) -> Option<&mut T>
Sourcepub fn remove(&mut self, id: Id<K>) -> Option<T>
pub fn remove(&mut self, id: Id<K>) -> Option<T>
Remove and return the value; stale ids get None.
pub fn iter(&self) -> impl Iterator<Item = (Id<K>, &T)>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl<K, T> Freeze for Arena<K, T>
impl<K, T> RefUnwindSafe for Arena<K, T>
impl<K, T> Send for Arena<K, T>
impl<K, T> Sync for Arena<K, T>
impl<K, T> Unpin for Arena<K, T>
impl<K, T> UnsafeUnpin for Arena<K, T>
impl<K, T> UnwindSafe for Arena<K, T>
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