pub struct GenMap<T> { /* private fields */ }Expand description
A collection of T’s referred to by Handle’s.
When you add an object to the GenMap it will
return a Handle, and you can look that item up
by that Handle. You can also remove the item,
which makes any old Handle’s to it become invalid
and attempting to get it will return None.
Implementations§
Source§impl<T> GenMap<T>
impl<T> GenMap<T>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a new empty GenMap with enough memory to accomodate
the given number of items without reallocating.
Sourcepub fn insert(&mut self, itm: T) -> Handle
pub fn insert(&mut self, itm: T) -> Handle
Insert the element into the map and return a handle referring to it.
Sourcepub fn get(&self, h: Handle) -> Option<&T>
pub fn get(&self, h: Handle) -> Option<&T>
Returns a reference to the item if the handle is valid,
or None otherwise.
Sourcepub fn get_mut(&mut self, h: Handle) -> Option<&mut T>
pub fn get_mut(&mut self, h: Handle) -> Option<&mut T>
Returns a mutable reference to the item if the handle is valid,
or None otherwise.
Sourcepub fn remove(&mut self, h: Handle) -> Option<T>
pub fn remove(&mut self, h: Handle) -> Option<T>
Removes the referenced item from the map, returning it. Returns None if the handle is stale.
pub fn iter(&self) -> Iterator<'_, T> ⓘ
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for GenMap<T>
impl<T> RefUnwindSafe for GenMap<T>where
T: RefUnwindSafe,
impl<T> Send for GenMap<T>where
T: Send,
impl<T> Sync for GenMap<T>where
T: Sync,
impl<T> Unpin for GenMap<T>where
T: Unpin,
impl<T> UnwindSafe for GenMap<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