Struct hecs::PreparedView
source · pub struct PreparedView<'q, Q: Query> { /* private fields */ }
Expand description
Provides random access to the results of a prepared query
Implementations§
source§impl<'q, Q: Query> PreparedView<'q, Q>
impl<'q, Q: Query> PreparedView<'q, Q>
sourcepub fn get(&self, entity: Entity) -> Option<Q::Item<'_>>where
Q: QueryShared,
pub fn get(&self, entity: Entity) -> Option<Q::Item<'_>>where
Q: QueryShared,
Retrieve the query results corresponding to entity
Will yield None
if the entity does not exist or does not match the query.
Does not require exclusive access to the map, but is defined only for queries yielding only shared references.
sourcepub fn get_mut(&mut self, entity: Entity) -> Option<Q::Item<'_>>
pub fn get_mut(&mut self, entity: Entity) -> Option<Q::Item<'_>>
Retrieve the query results corresponding to entity
Will yield None
if the entity does not exist or does not match the query.
sourcepub fn contains(&self, entity: Entity) -> bool
pub fn contains(&self, entity: Entity) -> bool
Equivalent to get(entity).is_some()
, but does not require Q: QueryShared
sourcepub unsafe fn get_unchecked(&self, entity: Entity) -> Option<Q::Item<'_>>
pub unsafe fn get_unchecked(&self, entity: Entity) -> Option<Q::Item<'_>>
Like get_mut
, but allows simultaneous access to multiple entities
Safety
Must not be invoked while any unique borrow of the fetched components of entity
is live.
sourcepub fn get_mut_n<const N: usize>(
&mut self,
entities: [Entity; N]
) -> [Option<Q::Item<'_>>; N]
pub fn get_mut_n<const N: usize>( &mut self, entities: [Entity; N] ) -> [Option<Q::Item<'_>>; N]
Like get_mut
, but allows checked simultaneous access to multiple entities
See View::get_mut_n
for details.
sourcepub fn iter_mut(&mut self) -> ViewIter<'_, Q>
pub fn iter_mut(&mut self) -> ViewIter<'_, Q>
Iterate over all entities satisfying Q
Equivalent to PreparedQueryBorrow::iter
.