Skip to main content

Has

Struct Has 

Source
pub struct Has<T>(PhantomData<fn() -> T>);
Expand description

Yields whether the archetype carries T.

The answer is read from the archetype’s component set, so it reaches no value and never conflicts: (&mut T, Has<T>) is legal. Use it instead of Option<&T>::is_some() to ask about a component without borrowing it.

It narrows nothing: every archetype matches, and a row whose archetype lacks T yields false. That is what lets a query report presence for rows it was going to visit anyway, and what keeps query_one::<Has<T>> answering Ok(false) rather than an error for an entity that lacks T. To visit only the archetypes carrying T, pair it with crate::QueryBorrow::by: .by(|archetype: &Archetype| archetype.has::<T>()).

Tuple Fields§

§0: PhantomData<fn() -> T>

Trait Implementations§

Source§

impl<T: Clone> Clone for Has<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Copy> Copy for Has<T>

Source§

impl<T: Debug> Debug for Has<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: 'static> Query for Has<T>

Source§

type Item<'a> = bool

What one matched row yields. Read more
Source§

type Plan<'w> = bool

What is resolved once per archetype and then read once per row. Read more
Source§

fn prepare<'w>(builder: &mut PlanBuilder<'w>) -> Option<Self::Plan<'w>>

Resolve the plan for one archetype. Read more
Source§

fn read<'a, 'w: 'a>(plan: &'a mut Self::Plan<'w>, _: usize) -> Self::Item<'a>

Read the row at row through the resolved plan. Read more

Auto Trait Implementations§

§

impl<T> Forget for Has<T>

§

impl<T> Freeze for Has<T>
where PhantomData<fn() -> T>: Freeze,

§

impl<T> RefUnwindSafe for Has<T>
where PhantomData<fn() -> T>: RefUnwindSafe,

§

impl<T> Send for Has<T>
where PhantomData<fn() -> T>: Send,

§

impl<T> Sync for Has<T>
where PhantomData<fn() -> T>: Sync,

§

impl<T> Unpin for Has<T>
where PhantomData<fn() -> T>: Unpin,

§

impl<T> UnsafeUnpin for Has<T>
where PhantomData<fn() -> T>: UnsafeUnpin,

§

impl<T> UnwindSafe for Has<T>
where PhantomData<fn() -> T>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Component for T
where T: 'static,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more