pub struct QueryMap<'q, S> where
S: QuerySpec, { /* private fields */ }
Expand description
Provides random access to the entities which match a certain Query.
Implementations
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);