pub struct Arena<T> { /* private fields */ }Expand description
Fixed-capacity generational arena.
Implementations§
Source§impl<T> Arena<T>
impl<T> Arena<T>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Allocate a new arena with capacity pre-reserved slots.
Sourcepub fn insert(&mut self, value: T) -> Option<NodeId>
pub fn insert(&mut self, value: T) -> Option<NodeId>
Insert a value, returning its generational id.
Returns None if the arena is full.
Sourcepub fn remove(&mut self, id: NodeId) -> Option<T>
pub fn remove(&mut self, id: NodeId) -> Option<T>
Remove a value by id. Returns the value if the id was valid.
Sourcepub fn get(&self, id: NodeId) -> Option<&T>
pub fn get(&self, id: NodeId) -> Option<&T>
Get a shared reference. Returns None for stale ids.
Sourcepub fn get_mut(&mut self, id: NodeId) -> Option<&mut T>
pub fn get_mut(&mut self, id: NodeId) -> Option<&mut T>
Get a mutable reference. Returns None for stale ids.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Auto Trait Implementations§
impl<T> Freeze for Arena<T>
impl<T> RefUnwindSafe for Arena<T>where
T: RefUnwindSafe,
impl<T> Send for Arena<T>where
T: Send,
impl<T> Sync for Arena<T>where
T: Sync,
impl<T> Unpin for Arena<T>where
T: Unpin,
impl<T> UnsafeUnpin for Arena<T>
impl<T> UnwindSafe for Arena<T>where
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more