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ₙ)>
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<()>
impl WorldQuery for Or<()>
SAFETY:
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
WorldQuery::set_table
must be used before
WorldQuery::fetch
can be called for iterators. If this returns false,
WorldQuery::set_archetype
must be used before WorldQuery::fetch
can be called for
iterators.Source§type Fetch<'w> = ()
type Fetch<'w> = ()
WorldQuery
to fetch Self::Item
Source§type Item<'w> = bool
type Item<'w> = bool
WorldQuery
For QueryData
this will be the item returned by the query.
For QueryFilter
this will be either ()
, or a bool
indicating whether the entity should be included
or a tuple of such things.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<'wlong: 'wshort, 'wshort>(
item: Self::Item<'wlong>,
) -> Self::Item<'wshort>
fn shrink<'wlong: 'wshort, 'wshort>( item: Self::Item<'wlong>, ) -> Self::Item<'wshort>
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>(
world: UnsafeWorldCell<'w>,
state: &Self::State,
last_run: Tick,
this_run: Tick,
) -> Self::Fetch<'w>
unsafe fn init_fetch<'w>( world: UnsafeWorldCell<'w>, state: &Self::State, last_run: Tick, this_run: Tick, ) -> Self::Fetch<'w>
Source§unsafe fn set_table<'w>(
fetch: &mut Self::Fetch<'w>,
state: &Self::State,
table: &'w Table,
)
unsafe fn set_table<'w>( fetch: &mut Self::Fetch<'w>, state: &Self::State, table: &'w Table, )
Table
. This will always be called on tables
that match this WorldQuery
. Read moreSource§unsafe fn set_archetype<'w>(
fetch: &mut Self::Fetch<'w>,
state: &Self::State,
archetype: &'w Archetype,
table: &'w Table,
)
unsafe fn set_archetype<'w>( fetch: &mut Self::Fetch<'w>, state: &Self::State, archetype: &'w Archetype, table: &'w Table, )
Archetype
. This will always be called on
archetypes that match this WorldQuery
. Read moreSource§unsafe fn fetch<'w>(
fetch: &mut Self::Fetch<'w>,
_entity: Entity,
_table_row: TableRow,
) -> Self::Item<'w>
unsafe fn fetch<'w>( fetch: &mut Self::Fetch<'w>, _entity: Entity, _table_row: TableRow, ) -> Self::Item<'w>
Self::Item
for either the given entity
in the current Table
,
or for the given entity
in the current Archetype
. This must always be called after
WorldQuery::set_table
with a table_row
in the range of the current Table
or after
WorldQuery::set_archetype
with a entity
in the current archetype. Read moreSource§fn update_component_access(
state: &Self::State,
access: &mut FilteredAccess<ComponentId>,
)
fn update_component_access( state: &Self::State, access: &mut FilteredAccess<ComponentId>, )
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§fn set_access(_state: &mut Self::State, _access: &FilteredAccess<ComponentId>)
fn set_access(_state: &mut Self::State, _access: &FilteredAccess<ComponentId>)
FilteredEntityRef
or FilteredEntityMut
. Read moreSource§impl<F: QueryFilter> WorldQuery for Or<(F₁, F₂, …, Fₙ)>
impl<F: QueryFilter> WorldQuery for Or<(F₁, F₂, …, Fₙ)>
This trait is implemented for tuples up to 16 items long.
SAFETY:
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 = _
WorldQuery::set_table
must be used before
WorldQuery::fetch
can be called for iterators. If this returns false,
WorldQuery::set_archetype
must be used before WorldQuery::fetch
can be called for
iterators.Source§type Fetch<'w> = (OrFetch<'w, F>,)
type Fetch<'w> = (OrFetch<'w, F>,)
WorldQuery
to fetch Self::Item
Source§type Item<'w> = bool
type Item<'w> = bool
WorldQuery
For QueryData
this will be the item returned by the query.
For QueryFilter
this will be either ()
, or a bool
indicating whether the entity should be included
or a tuple of such things.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<'wlong: 'wshort, 'wshort>(
item: Self::Item<'wlong>,
) -> Self::Item<'wshort>
fn shrink<'wlong: 'wshort, 'wshort>( item: Self::Item<'wlong>, ) -> Self::Item<'wshort>
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>(
world: UnsafeWorldCell<'w>,
state: &Self::State,
last_run: Tick,
this_run: Tick,
) -> Self::Fetch<'w>
unsafe fn init_fetch<'w>( world: UnsafeWorldCell<'w>, state: &Self::State, last_run: Tick, this_run: Tick, ) -> Self::Fetch<'w>
Source§unsafe fn set_table<'w>(
fetch: &mut Self::Fetch<'w>,
state: &Self::State,
table: &'w Table,
)
unsafe fn set_table<'w>( fetch: &mut Self::Fetch<'w>, state: &Self::State, table: &'w Table, )
Table
. This will always be called on tables
that match this WorldQuery
. Read moreSource§unsafe fn set_archetype<'w>(
fetch: &mut Self::Fetch<'w>,
state: &Self::State,
archetype: &'w Archetype,
table: &'w Table,
)
unsafe fn set_archetype<'w>( fetch: &mut Self::Fetch<'w>, state: &Self::State, archetype: &'w Archetype, table: &'w Table, )
Archetype
. This will always be called on
archetypes that match this WorldQuery
. Read moreSource§unsafe fn fetch<'w>(
fetch: &mut Self::Fetch<'w>,
_entity: Entity,
_table_row: TableRow,
) -> Self::Item<'w>
unsafe fn fetch<'w>( fetch: &mut Self::Fetch<'w>, _entity: Entity, _table_row: TableRow, ) -> Self::Item<'w>
Self::Item
for either the given entity
in the current Table
,
or for the given entity
in the current Archetype
. This must always be called after
WorldQuery::set_table
with a table_row
in the range of the current Table
or after
WorldQuery::set_archetype
with a entity
in the current archetype. Read moreSource§fn update_component_access(
state: &Self::State,
access: &mut FilteredAccess<ComponentId>,
)
fn update_component_access( state: &Self::State, access: &mut FilteredAccess<ComponentId>, )
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§fn set_access(_state: &mut Self::State, _access: &FilteredAccess<ComponentId>)
fn set_access(_state: &mut Self::State, _access: &FilteredAccess<ComponentId>)
FilteredEntityRef
or FilteredEntityMut
. Read moreimpl 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>
. 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>
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)
&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.