Struct flatbox_ecs::With
source · pub struct With<Q, R>(/* private fields */);
Expand description
Query transformer skipping entities that do not satisfy another query
See also QueryBorrow::with
.
§Example
let mut world = World::new();
let a = world.spawn((123, true, "abc"));
let b = world.spawn((456, false));
let c = world.spawn((42, "def"));
let entities = world.query::<With<&i32, &bool>>()
.iter()
.map(|(e, &i)| (e, i))
.collect::<Vec<_>>();
assert_eq!(entities.len(), 2);
assert!(entities.contains(&(a, 123)));
assert!(entities.contains(&(b, 456)));
Trait Implementations§
Auto Trait Implementations§
impl<Q, R> Freeze for With<Q, R>
impl<Q, R> RefUnwindSafe for With<Q, R>where
Q: RefUnwindSafe,
impl<Q, R> Send for With<Q, R>where
Q: Send,
impl<Q, R> Sync for With<Q, R>where
Q: Sync,
impl<Q, R> Unpin for With<Q, R>where
Q: Unpin,
impl<Q, R> UnwindSafe for With<Q, R>where
Q: UnwindSafe,
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
source§impl<'a, Q> ComponentBorrow for Qwhere
Q: Query,
impl<'a, Q> ComponentBorrow for Qwhere
Q: Query,
source§impl<T> Downcast for T
impl<T> Downcast for T
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<'a, Q> Subset for Qwhere
Q: Query,
impl<'a, Q> Subset for Qwhere
Q: Query,
source§fn is_subset<U>() -> boolwhere
U: ComponentBorrow,
fn is_subset<U>() -> boolwhere
U: ComponentBorrow,
Returns true if U is a subset of Self
source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.