pub struct MemoryStorage<T, U>{ /* private fields */ }Expand description
The instance that will store all the items.
Implementations§
Source§impl<T> MemoryStorage<T, SlotVec<T>>
impl<T> MemoryStorage<T, SlotVec<T>>
Source§impl<T, U> MemoryStorage<T, U>
impl<T, U> MemoryStorage<T, U>
Sourcepub fn insert(&mut self, item: T) -> Result<Id, InternalStorageFullError<T>>
pub fn insert(&mut self, item: T) -> Result<Id, InternalStorageFullError<T>>
Try to insert an item. Returning the ID on a successful insert and returning the item wrapped in an error whenever there’s no space left.
Sourcepub fn remove(&mut self, id: Id) -> T
pub fn remove(&mut self, id: Id) -> T
Removes an item without shifting the items after it to the left and without invalidating their IDs.
Sourcepub fn get_mut(&mut self, id: Id) -> Option<&mut T>
pub fn get_mut(&mut self, id: Id) -> Option<&mut T>
Returns a mutable reference to an item whenever it is present.
Sourcepub fn taken_slots(&self) -> usize
pub fn taken_slots(&self) -> usize
Returns how many slots are currently in use.
Sourcepub fn storage_ref(&self) -> &U
pub fn storage_ref(&self) -> &U
Acquire a reference to the storage.
Auto Trait Implementations§
impl<T, U> Freeze for MemoryStorage<T, U>where
U: Freeze,
impl<T, U> RefUnwindSafe for MemoryStorage<T, U>where
U: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, U> Send for MemoryStorage<T, U>
impl<T, U> Sync for MemoryStorage<T, U>
impl<T, U> Unpin for MemoryStorage<T, U>
impl<T, U> UnwindSafe for MemoryStorage<T, U>where
U: UnwindSafe,
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