Enum specs::storage::StorageEntry
source · pub enum StorageEntry<'a, 'b: 'a, T: 'a, D: 'a> {
Occupied(OccupiedEntry<'a, 'b, T, D>),
Vacant(VacantEntry<'a, 'b, T, D>),
}
Expand description
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 does has a component.
Vacant(VacantEntry<'a, 'b, T, D>)
Entry variant that is returned if the entity does not have a component.
Implementations
sourceimpl<'a, 'b, T, D> StorageEntry<'a, 'b, T, D>where
T: Component,
D: DerefMut<Target = MaskedStorage<T>>,
impl<'a, 'b, T, D> StorageEntry<'a, 'b, T, D>where
T: Component,
D: DerefMut<Target = MaskedStorage<T>>,
sourcepub fn or_insert(self, component: T) -> &'a mut T
pub fn or_insert(self, component: T) -> &'a mut T
Inserts a component if the entity does not contain a component.
sourcepub fn or_insert_with<F>(self, default: F) -> &'a mut Twhere
F: FnOnce() -> T,
pub fn or_insert_with<F>(self, default: F) -> &'a mut Twhere
F: FnOnce() -> T,
Inserts a component using a lazily called function that is only called when inserting the component.
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>where
D: Send,
T: Send,
impl<'a, 'b, T, D> Sync for StorageEntry<'a, 'b, T, D>where
D: Sync,
T: Sync,
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more