[−][src]Struct yaks::QueryMarker
A zero-sized Copy
type used to describe queries of a system, and prepare them
via methods of SystemContext
.
Instantiating these directly is only useful when calling systems as plain functions,
and can be done either by QueryMarker::new()
, QueryMarker::default()
, or
Default::default()
, the latter of which can also instantiate tuples of markers (up to 10):
fn single_query(context: SystemContext, average: &mut f32, query: QueryMarker<&f32>) { *average = 0f32; let mut entities = 0; for (_entity, value) in context.query(query).iter() { entities += 1; *average += *value; } *average /= entities as f32; } single_query(world.into(), &mut average, QueryMarker::new()); single_query(world.into(), &mut average, QueryMarker::default()); single_query(world.into(), &mut average, Default::default()); fn two_queries( context: SystemContext, average: &mut f32, (floats, ints): (QueryMarker<&f32>, QueryMarker<&i32>), ) { *average = 0f32; let mut entities = 0; for (_entity, value) in context.query(floats).iter() { entities += 1; *average += *value; } for (_entity, value) in context.query(ints).iter() { entities += 1; *average += *value as f32; } *average /= entities as f32; } two_queries(world.into(), &mut average, Default::default());
Instantiating markers inside a system is improper!
While it's possible to instantiate a marker within a system and use it to prepare a query, doing so does not inform the executor the system may be in of said query, and may lead to a panic.
Implementations
impl<Q0> QueryMarker<Q0> where
Q0: Query,
[src]
Q0: Query,
pub fn new() -> Self
[src]
Equivalent to QueryMarker::default()
. See documentation for QueryMarker
itself.
Trait Implementations
impl<Q0> Clone for QueryMarker<Q0> where
Q0: Query,
[src]
Q0: Query,
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<Q0> Copy for QueryMarker<Q0> where
Q0: Query,
[src]
Q0: Query,
impl<Q0> Default for QueryMarker<Q0> where
Q0: Query,
[src]
Q0: Query,
Auto Trait Implementations
impl<Q0> RefUnwindSafe for QueryMarker<Q0> where
Q0: RefUnwindSafe,
Q0: RefUnwindSafe,
impl<Q0> Send for QueryMarker<Q0> where
Q0: Send,
Q0: Send,
impl<Q0> Sync for QueryMarker<Q0> where
Q0: Sync,
Q0: Sync,
impl<Q0> Unpin for QueryMarker<Q0> where
Q0: Unpin,
Q0: Unpin,
impl<Q0> UnwindSafe for QueryMarker<Q0> where
Q0: UnwindSafe,
Q0: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Component for T where
T: 'static + Send + Sync,
[src]
T: 'static + Send + Sync,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,