Struct MapRefMut

Source
pub struct MapRefMut<'a, T> { /* private fields */ }
Expand description

Mutable reference container for Persist returned by Entities::borrow_mut()

This struct is required to contain a hidden borrow to the requested Persist. The reason for this is so we can borrow multiple Persist, but not break the borrow checker rules for borrows on a single Persist.

Methods from Deref<Target = Persist<T>>§

Source

pub fn len(&self) -> usize

Returns the actual used length regardless of capacity

Source

pub fn is_empty(&self) -> bool

Source

pub fn capacity(&self) -> usize

Returns the storage capacity

Source

pub fn clear(&mut self)

Clear the storage out while keeping allocated memory

Should not ever panic

Source

pub fn get(&self, index: usize) -> Option<&T>

Source

pub fn get_mut(&mut self, index: usize) -> Option<&mut T>

Source

pub fn is_index_live(&self, index: usize) -> bool

Check if there is a value at this index

Source

pub fn push(&mut self, value: T) -> Option<usize>

Push T on to storage.

A push is not guaranteed to push in any particular order if the internal storage has empty locations (typical after many remove). For this reason it will return the index pushed to.

Returns None if there are no free slots left

Source

pub fn insert(&mut self, index: usize, value: T) -> Option<T>

Insert T at location. Returns existing value in that location or None.

§Panics

Will panic is the index is out of range

Source

pub fn pop(&mut self) -> Option<T>

Pop the last value in the Persist

Source

pub fn remove(&mut self, index: usize) -> Option<T>

Remove the item at this index and return it if it exists. Does not shift elements after it to the left.

Source

pub fn iter(&self) -> Iter<'_, T>

Source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

Trait Implementations§

Source§

impl<'a, T> Deref for MapRefMut<'a, T>

Source§

type Target = Persist<T>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Persist<T>

Dereferences the value.
Source§

impl<'a, T> DerefMut for MapRefMut<'a, T>

Source§

fn deref_mut(&mut self) -> &mut Persist<T>

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'a, T> Freeze for MapRefMut<'a, T>

§

impl<'a, T> !RefUnwindSafe for MapRefMut<'a, T>

§

impl<'a, T> !Send for MapRefMut<'a, T>

§

impl<'a, T> !Sync for MapRefMut<'a, T>

§

impl<'a, T> Unpin for MapRefMut<'a, T>

§

impl<'a, T> !UnwindSafe for MapRefMut<'a, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.