pub struct Query<'a, Q: Query> { /* private fields */ }Expand description
Fetches components matching Q from every entity that has them. Include
Entity in Q to get entity IDs back out of iteration.
Implementations§
Source§impl<'a, Q: Query> Query<'a, Q>
impl<'a, Q: Query> Query<'a, Q>
Sourcepub fn iter(&mut self) -> impl Iterator<Item = Q::Item<'_>>
pub fn iter(&mut self) -> impl Iterator<Item = Q::Item<'_>>
Iterates every matching entity’s components.
Sourcepub fn get(&mut self, entity: Entity) -> Option<Q::Item<'_>>
pub fn get(&mut self, entity: Entity) -> Option<Q::Item<'_>>
Fetches one known entity directly, without scanning the rest of the
query. None if it doesn’t exist or doesn’t match Q.
Sourcepub fn with<R: Query>(self) -> Query<'a, With<Q, R>>
pub fn with<R: Query>(self) -> Query<'a, With<Q, R>>
Narrows to entities that also have component(s) R, without R
joining the yielded items. Chainable with .without::<S>().
Sourcepub fn without<R: Query>(self) -> Query<'a, Without<Q, R>>
pub fn without<R: Query>(self) -> Query<'a, Without<Q, R>>
Narrows to entities that don’t have component(s) R.
Sourcepub fn single(&mut self) -> Q::Item<'_>
pub fn single(&mut self) -> Q::Item<'_>
Expects exactly one matching entity (the player, the active
camera). Panics otherwise — use get_single if
that’s not guaranteed.
Sourcepub fn get_single(&mut self) -> Option<Q::Item<'_>>
pub fn get_single(&mut self) -> Option<Q::Item<'_>>
Same as single, but None instead of panicking
when there isn’t exactly one match.
Trait Implementations§
Source§impl<'a, Q: Query> IntoIterator for &'a mut Query<'a, Q>
impl<'a, Q: Query> IntoIterator for &'a mut Query<'a, Q>
Auto Trait Implementations§
impl<'a, Q> Freeze for Query<'a, Q>
impl<'a, Q> RefUnwindSafe for Query<'a, Q>
impl<'a, Q> Send for Query<'a, Q>
impl<'a, Q> Sync for Query<'a, Q>
impl<'a, Q> Unpin for Query<'a, Q>where
Q: Unpin,
impl<'a, Q> UnsafeUnpin for Query<'a, Q>
impl<'a, Q> UnwindSafe for Query<'a, Q>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> Component for T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more