Skip to main content

QueryOne

Struct QueryOne 

Source
pub struct QueryOne<'w, Q: Query> {
    row: usize,
    plan: Q::Plan<'w>,
    _claims: Claims<'w>,
    marker: PhantomData<fn() -> Q>,
}
Expand description

What a scope hands out for a query over one entity.

Made by crate::Scope::query_one, which claims the components the query reaches on that entity’s row. A missing match is still answered with an error rather than a holder, so a caller that finds nothing holds no claim.

QueryOne::get is what reads the row, and it takes the holder exclusively: an exclusive item borrows from the call, so the compiler refuses a second one while the first is alive.

Fields§

§row: usize§plan: Q::Plan<'w>§_claims: Claims<'w>

Held for the life of the holder: dropping it is what releases the claim.

§marker: PhantomData<fn() -> Q>

Implementations§

Source§

impl<'w, Q: Query> QueryOne<'w, Q>

Source

pub(crate) fn new(plan: Q::Plan<'w>, row: usize, claims: Claims<'w>) -> Self

Source

pub fn get(&mut self) -> Q::Item<'_>

What the query yields for this entity’s row.

Trait Implementations§

Source§

impl<Q: Query> Debug for QueryOne<'_, Q>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'w, Q> !RefUnwindSafe for QueryOne<'w, Q>

§

impl<'w, Q> !Send for QueryOne<'w, Q>

§

impl<'w, Q> !Sync for QueryOne<'w, Q>

§

impl<'w, Q> !UnwindSafe for QueryOne<'w, Q>

§

impl<'w, Q> Forget for QueryOne<'w, Q>

§

impl<'w, Q> Freeze for QueryOne<'w, Q>
where <Q as Query>::Plan<'w>: Freeze, PhantomData<fn() -> Q>: Freeze,

§

impl<'w, Q> Unpin for QueryOne<'w, Q>
where <Q as Query>::Plan<'w>: Unpin, PhantomData<fn() -> Q>: Unpin,

§

impl<'w, Q> UnsafeUnpin for QueryOne<'w, Q>
where <Q as Query>::Plan<'w>: UnsafeUnpin, PhantomData<fn() -> Q>: UnsafeUnpin,

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> Component for T
where T: 'static,

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, 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