pub struct Or<T>(/* private fields */);Expand description
A filter that tests if any of the given filters apply.
This is useful for example if a system with multiple components in a query only wants to run when one or more of the components have changed.
The And equivalent to this filter is a tuple testing that all the contained filters
apply instead.
§Examples
fn print_cool_entity_system(query: Query<Entity, Or<(Changed<Color>, Changed<Node>)>>) {
for entity in &query {
println!("Entity {} got a new style or color", entity);
}
}Trait Implementations§
Source§impl QueryFilter for Or<()>
impl QueryFilter for Or<()>
Source§const IS_ARCHETYPAL: bool = true
const IS_ARCHETYPAL: bool = true
Source§impl<F: QueryFilter> QueryFilter for Or<(F₁, F₂, …, Fₙ)>
This trait is implemented for tuples up to 16 items long.
impl<F: QueryFilter> QueryFilter for Or<(F₁, F₂, …, Fₙ)>
This trait is implemented for tuples up to 16 items long.
Source§const IS_ARCHETYPAL: bool
const IS_ARCHETYPAL: bool
Source§impl WorldQuery for Or<()>
SAFETY:
QueryFilter::filter_fetch accesses are a subset of the subqueries’ accesses
This is sound because update_component_access adds accesses according to the implementations of all the subqueries.
update_component_access replace the filters with a disjunction where every element is a conjunction of the previous filters and the filters of one of the subqueries.
This is sound because matches_component_set returns a disjunction of the results of the subqueries’ implementations.
impl WorldQuery for Or<()>
SAFETY:
QueryFilter::filter_fetch accesses are a subset of the subqueries’ accesses
This is sound because update_component_access adds accesses according to the implementations of all the subqueries.
update_component_access replace the filters with a disjunction where every element is a conjunction of the previous filters and the filters of one of the subqueries.
This is sound because matches_component_set returns a disjunction of the results of the subqueries’ implementations.
Source§const IS_DENSE: bool = true
const IS_DENSE: bool = true
Source§type Fetch<'w> = ()
type Fetch<'w> = ()
WorldQuery to compute Self::Item for each entity.Source§type State = ()
type State = ()
Self::Fetch. This will be cached inside QueryState,
so it is best to move as much data / computation here as possible to reduce the cost of
constructing Self::Fetch.Source§fn shrink_fetch<'wlong: 'wshort, 'wshort>(
fetch: Self::Fetch<'wlong>,
) -> Self::Fetch<'wshort>
fn shrink_fetch<'wlong: 'wshort, 'wshort>( fetch: Self::Fetch<'wlong>, ) -> Self::Fetch<'wshort>
Source§unsafe fn init_fetch<'w, 's>(
world: UnsafeWorldCell<'w>,
state: &'s Self::State,
last_run: Tick,
this_run: Tick,
) -> Self::Fetch<'w>
unsafe fn init_fetch<'w, 's>( world: UnsafeWorldCell<'w>, state: &'s Self::State, last_run: Tick, this_run: Tick, ) -> Self::Fetch<'w>
Self::Fetch,
by combining data from the World with the cached Self::State.
Readonly accesses resources registered in WorldQuery::update_component_access. Read moreSource§unsafe fn set_table<'w, 's>(
fetch: &mut Self::Fetch<'w>,
state: &'s Self::State,
table: &'w Table,
)
unsafe fn set_table<'w, 's>( fetch: &mut Self::Fetch<'w>, state: &'s Self::State, table: &'w Table, )
Table. This will always be called on tables
that match this WorldQuery. Read moreSource§unsafe fn set_archetype<'w, 's>(
fetch: &mut Self::Fetch<'w>,
state: &'s Self::State,
archetype: &'w Archetype,
table: &'w Table,
)
unsafe fn set_archetype<'w, 's>( fetch: &mut Self::Fetch<'w>, state: &'s Self::State, archetype: &'w Archetype, table: &'w Table, )
Archetype. This will always be called on
archetypes that match this WorldQuery. Read moreSource§fn update_component_access(state: &Self::State, access: &mut FilteredAccess)
fn update_component_access(state: &Self::State, access: &mut FilteredAccess)
Source§fn init_state(world: &mut World) -> Self::State
fn init_state(world: &mut World) -> Self::State
State for this WorldQuery type.Source§fn matches_component_set(
state: &Self::State,
set_contains_id: &impl Fn(ComponentId) -> bool,
) -> bool
fn matches_component_set( state: &Self::State, set_contains_id: &impl Fn(ComponentId) -> bool, ) -> bool
Source§impl<F: QueryFilter> WorldQuery for Or<(F₁, F₂, …, Fₙ)>
This trait is implemented for tuples up to 16 items long.
SAFETY:
QueryFilter::filter_fetch accesses are a subset of the subqueries’ accesses
This is sound because update_component_access adds accesses according to the implementations of all the subqueries.
update_component_access replace the filters with a disjunction where every element is a conjunction of the previous filters and the filters of one of the subqueries.
This is sound because matches_component_set returns a disjunction of the results of the subqueries’ implementations.
impl<F: QueryFilter> WorldQuery for Or<(F₁, F₂, …, Fₙ)>
This trait is implemented for tuples up to 16 items long.
SAFETY:
QueryFilter::filter_fetch accesses are a subset of the subqueries’ accesses
This is sound because update_component_access adds accesses according to the implementations of all the subqueries.
update_component_access replace the filters with a disjunction where every element is a conjunction of the previous filters and the filters of one of the subqueries.
This is sound because matches_component_set returns a disjunction of the results of the subqueries’ implementations.
Source§const IS_DENSE: bool
const IS_DENSE: bool
Source§type Fetch<'w> = (OrFetch<'w, F>,)
type Fetch<'w> = (OrFetch<'w, F>,)
WorldQuery to compute Self::Item for each entity.Source§type State = (<F as WorldQuery>::State,)
type State = (<F as WorldQuery>::State,)
Self::Fetch. This will be cached inside QueryState,
so it is best to move as much data / computation here as possible to reduce the cost of
constructing Self::Fetch.Source§fn shrink_fetch<'wlong: 'wshort, 'wshort>(
fetch: Self::Fetch<'wlong>,
) -> Self::Fetch<'wshort>
fn shrink_fetch<'wlong: 'wshort, 'wshort>( fetch: Self::Fetch<'wlong>, ) -> Self::Fetch<'wshort>
Source§unsafe fn init_fetch<'w, 's>(
world: UnsafeWorldCell<'w>,
state: &'s Self::State,
last_run: Tick,
this_run: Tick,
) -> Self::Fetch<'w>
unsafe fn init_fetch<'w, 's>( world: UnsafeWorldCell<'w>, state: &'s Self::State, last_run: Tick, this_run: Tick, ) -> Self::Fetch<'w>
Self::Fetch,
by combining data from the World with the cached Self::State.
Readonly accesses resources registered in WorldQuery::update_component_access. Read moreSource§unsafe fn set_table<'w, 's>(
fetch: &mut Self::Fetch<'w>,
state: &'s Self::State,
table: &'w Table,
)
unsafe fn set_table<'w, 's>( fetch: &mut Self::Fetch<'w>, state: &'s Self::State, table: &'w Table, )
Table. This will always be called on tables
that match this WorldQuery. Read moreSource§unsafe fn set_archetype<'w, 's>(
fetch: &mut Self::Fetch<'w>,
state: &'s Self::State,
archetype: &'w Archetype,
table: &'w Table,
)
unsafe fn set_archetype<'w, 's>( fetch: &mut Self::Fetch<'w>, state: &'s Self::State, archetype: &'w Archetype, table: &'w Table, )
Archetype. This will always be called on
archetypes that match this WorldQuery. Read moreSource§fn update_component_access(state: &Self::State, access: &mut FilteredAccess)
fn update_component_access(state: &Self::State, access: &mut FilteredAccess)
Source§fn init_state(world: &mut World) -> Self::State
fn init_state(world: &mut World) -> Self::State
State for this WorldQuery type.Source§fn matches_component_set(
state: &Self::State,
set_contains_id: &impl Fn(ComponentId) -> bool,
) -> bool
fn matches_component_set( state: &Self::State, set_contains_id: &impl Fn(ComponentId) -> bool, ) -> bool
impl ArchetypeFilter for Or<()>
impl<F: ArchetypeFilter> ArchetypeFilter for Or<(F₁, F₂, …, Fₙ)>
This trait is implemented for tuples up to 16 items long.
Auto Trait Implementations§
impl<T> Freeze for Or<T>
impl<T> RefUnwindSafe for Or<T>where
T: RefUnwindSafe,
impl<T> Send for Or<T>where
T: Send,
impl<T> Sync for Or<T>where
T: Sync,
impl<T> Unpin for Or<T>where
T: Unpin,
impl<T> UnwindSafe for Or<T>where
T: 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
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>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn 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>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which 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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.