[][src]Enum oxygengine_core::ecs::storage::StorageEntry

pub enum StorageEntry<'a, 'b, T, D> where
    'b: 'a,
    D: 'a,
    T: 'a, 
{ Occupied(OccupiedEntry<'a, 'b, T, D>), Vacant(VacantEntry<'a, 'b, T, D>), }

Entry to a storage for convenient filling of components or removal based on whether the entity has a component.

Variants

Occupied(OccupiedEntry<'a, 'b, T, D>)

Entry variant that is returned if the entity has a component.

Vacant(VacantEntry<'a, 'b, T, D>)

Entry variant that is returned if the entity does not have a component.

Implementations

impl<'a, 'b, T, D> StorageEntry<'a, 'b, T, D> where
    D: DerefMut<Target = MaskedStorage<T>>,
    T: Component
[src]

pub fn replace(self, component: T) -> Option<T>[src]

Inserts a component and returns the old value in case this entry was already occupied.

pub fn or_insert(self, component: T) -> &'a mut T[src]

Inserts a component if the entity does not have it already.

pub fn or_insert_with<F>(self, default: F) -> &'a mut T where
    F: FnOnce() -> T, 
[src]

Inserts a component using a lazily called function that is only called when inserting the component. Ensures this entry has a value and if not, inserts one using the result of the passed closure. Returns a reference to the value afterwards.

Auto Trait Implementations

impl<'a, 'b, T, D> !RefUnwindSafe for StorageEntry<'a, 'b, T, D>

impl<'a, 'b, T, D> !Send for StorageEntry<'a, 'b, T, D>

impl<'a, 'b, T, D> !Sync for StorageEntry<'a, 'b, T, D>

impl<'a, 'b, T, D> Unpin for StorageEntry<'a, 'b, T, D> where
    'b: 'a, 

impl<'a, 'b, T, D> !UnwindSafe for StorageEntry<'a, 'b, T, D>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Any for T where
    T: Any

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Resource for T where
    T: Any, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,