pub struct QueryMap<'q, S> where
S: QuerySpec, { /* private fields */ }
Expand description
Provides random access to the entities which match a certain Query.
Implementations
sourceimpl<S> QueryMap<'_, S> where
S: QuerySpec,
impl<S> QueryMap<'_, S> where
S: QuerySpec,
sourcepub fn get<'m>(&'m self, ent: Entity) -> Option<<S::Fetch as Fetch<'m>>::Item> where
S::Fetch: FetchShared,
pub fn get<'m>(&'m self, ent: Entity) -> Option<<S::Fetch as Fetch<'m>>::Item> where
S::Fetch: FetchShared,
Access the queried components of the given Entity
Examples
let mut world = World::new();
let entity1 = world.alloc();
world.insert(entity1, (42_i32, 1.0_f32));
let entity2 = world.alloc();
world.insert(entity2, (23_i32,));
let mut query = Query::<(&i32, Option<&f32>)>::new();
let mut query = query.borrow(&world);
let mut query = query.map();
let (i1, f1) = query.get(entity1).unwrap();
let (i2, f2) = query.get(entity2).unwrap();
assert_eq!(*i1, 42);
assert_eq!(f1.copied(), Some(1.0));
assert_eq!(*i2, 23);
assert_eq!(f2.copied(), None);
Auto Trait Implementations
impl<'q, S> RefUnwindSafe for QueryMap<'q, S> where
<<S as QuerySpec>::Fetch as Fetch<'q>>::Ptr: RefUnwindSafe,
impl<'q, S> Send for QueryMap<'q, S> where
<<S as QuerySpec>::Fetch as Fetch<'q>>::Ptr: Sync,
impl<'q, S> Sync for QueryMap<'q, S> where
<<S as QuerySpec>::Fetch as Fetch<'q>>::Ptr: Sync,
impl<'q, S> Unpin for QueryMap<'q, S>
impl<'q, S> UnwindSafe for QueryMap<'q, S> where
<<S as QuerySpec>::Fetch as Fetch<'q>>::Ptr: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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