Struct rs_ecs::Query [−][src]
pub struct Query<S> where
S: QuerySpec, { /* fields omitted */ }Expand description
Query to get an iterator over all entities with a certain combination of components.
Queries are provided as stand-alone structs to allow for prepared queries that can be re-used, as an optimzation. Hence, queries neet to borrow the World before their results can be iterated (see Query::borrow).
Examples
let mut world = World::new(); let entity = world.alloc(); world.insert(entity, (0_i32, true)); let entity = world.alloc(); world.insert(entity, (42_i32, 23_u32, 1.0_f32)); let mut query = Query::<(&i32, &mut bool)>::new(); for (i, b) in query.borrow(&world).iter() { *b = *i > 10; }
Implementations
impl<S> Query<S> where
S: QuerySpec, [src]
impl<S> Query<S> where
S: QuerySpec, [src]pub fn new() -> Self[src]
pub fn new() -> Self[src]Create a query.
Examples
let mut immutable_query = Query::<(&i32,)>::new(); let mut mutable_query = Query::<(&i32, &mut bool)>::new(); let mut query_with_entity = Query::<(&Entity, &i32, &mut bool)>::new();
Trait Implementations
Auto Trait Implementations
impl<S> RefUnwindSafe for Query<S> where
<<S as QuerySpec>::Fetch as Fetch<'static>>::Ref: RefUnwindSafe,
<<S as QuerySpec>::Fetch as Fetch<'static>>::Ty: RefUnwindSafe,
<<S as QuerySpec>::Fetch as Fetch<'static>>::Ref: RefUnwindSafe,
<<S as QuerySpec>::Fetch as Fetch<'static>>::Ty: RefUnwindSafe,
impl<S> Send for Query<S> where
<<S as QuerySpec>::Fetch as Fetch<'static>>::Ref: Send,
<<S as QuerySpec>::Fetch as Fetch<'static>>::Ty: Send,
<<S as QuerySpec>::Fetch as Fetch<'static>>::Ref: Send,
<<S as QuerySpec>::Fetch as Fetch<'static>>::Ty: Send,
impl<S> Sync for Query<S> where
<<S as QuerySpec>::Fetch as Fetch<'static>>::Ref: Sync,
<<S as QuerySpec>::Fetch as Fetch<'static>>::Ty: Sync,
<<S as QuerySpec>::Fetch as Fetch<'static>>::Ref: Sync,
<<S as QuerySpec>::Fetch as Fetch<'static>>::Ty: Sync,
impl<S> Unpin for Query<S> where
<<S as QuerySpec>::Fetch as Fetch<'static>>::Ref: Unpin,
<<S as QuerySpec>::Fetch as Fetch<'static>>::Ty: Unpin,
<<S as QuerySpec>::Fetch as Fetch<'static>>::Ref: Unpin,
<<S as QuerySpec>::Fetch as Fetch<'static>>::Ty: Unpin,
impl<S> UnwindSafe for Query<S> where
<<S as QuerySpec>::Fetch as Fetch<'static>>::Ref: UnwindSafe,
<<S as QuerySpec>::Fetch as Fetch<'static>>::Ty: UnwindSafe,
<<S as QuerySpec>::Fetch as Fetch<'static>>::Ref: UnwindSafe,
<<S as QuerySpec>::Fetch as Fetch<'static>>::Ty: UnwindSafe,