Ref

Struct Ref 

Source
pub struct Ref<'w, T: ?Sized> { /* private fields */ }
Expand description

A custom version of bevy’s Ref that can be constructed from EntityRef and mapped over.

Due to a limitation in bevy, it’s impossible to use the bevy Ref for this crate.

Implementations§

Source§

impl<'w, T: ?Sized> Ref<'w, T>

Source

pub const fn is_added(&self) -> bool

Was this added since last time the system this is called from ran?

Source

pub const fn is_changed(&self) -> bool

Was this changed since last time the system this is called from ran?

Source

pub const fn into_inner(self) -> &'w T

Return the inner reference with its full lifetime.

Rust’s Deref trait can’t produce references with a lifetime longer than that of the Ref itself (with &'a Ref<'w>, the lifetime will always be 'a).

This can become an issue in certain scenarios, this is why this method exists.

Note that since Ref is Copy, this doesn’t consume the value, you can keep using it.

Source

pub fn map_failable<E, U: ?Sized>( self, f: impl FnOnce(&T) -> Result<&U, E>, ) -> Result<Ref<'w, U>, E>

Apply a function f returning a result to the inner value, and get a Ref with the return value of that function. Returning Err if f returns Err.

§Errors

Returns Err if f returns Err.

Source

pub fn map<U: ?Sized>(self, f: impl FnOnce(&T) -> &U) -> Ref<'w, U>

Apply a function f to the inner value, and get a Ref with the return value of that function.

Source

pub fn map_from<U: ?Sized>(bevy: BRef<'w, U>, f: impl FnOnce(&U) -> &T) -> Self

Convert a bevy Ref into a reflect_query Ref, applying a function while converting it.

You can pass |i| i as function if you don’t wish to convert the value.

Trait Implementations§

Source§

impl<'w, T: ?Sized> AsRef<T> for Ref<'w, T>

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'w, T: Clone + ?Sized> Clone for Ref<'w, T>

Source§

fn clone(&self) -> Ref<'w, T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'w, T: Debug + ?Sized> Debug for Ref<'w, T>

Source§

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

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

impl<'w, T: ?Sized> Deref for Ref<'w, T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'w, T: ?Sized> From<Ref<'w, T>> for Ref<'w, T>

Source§

fn from(value: BRef<'w, T>) -> Self

Converts to this type from the input type.
Source§

impl<'w, 'a, T> IntoIterator for &'a Ref<'w, T>

Source§

type Item = <&'a T as IntoIterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = <&'a T as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'w, T: Ord + ?Sized> Ord for Ref<'w, T>

Source§

fn cmp(&self, other: &Ref<'w, T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<'w, T: PartialEq + ?Sized> PartialEq for Ref<'w, T>

Source§

fn eq(&self, other: &Ref<'w, T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'w, T: PartialOrd + ?Sized> PartialOrd for Ref<'w, T>

Source§

fn partial_cmp(&self, other: &Ref<'w, T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'w, T: Copy + ?Sized> Copy for Ref<'w, T>

Source§

impl<'w, T: Eq + ?Sized> Eq for Ref<'w, T>

Source§

impl<'w, T: ?Sized> StructuralPartialEq for Ref<'w, T>

Auto Trait Implementations§

§

impl<'w, T> Freeze for Ref<'w, T>
where T: ?Sized,

§

impl<'w, T> RefUnwindSafe for Ref<'w, T>
where T: RefUnwindSafe + ?Sized,

§

impl<'w, T> Send for Ref<'w, T>
where T: Sync + ?Sized,

§

impl<'w, T> Sync for Ref<'w, T>
where T: Sync + ?Sized,

§

impl<'w, T> Unpin for Ref<'w, T>
where T: ?Sized,

§

impl<'w, T> UnwindSafe for Ref<'w, T>
where T: RefUnwindSafe + ?Sized,

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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

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

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynEq for T
where T: Any + Eq,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Casts the type to dyn Any.
Source§

fn dyn_eq(&self, other: &(dyn DynEq + 'static)) -> bool

This method tests for self and other values to be equal. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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<S, T> ParallelSlice<T> for S
where T: Sync, S: AsRef<[T]>,

Source§

fn par_chunk_map<F, R>( &self, task_pool: &TaskPool, chunk_size: usize, f: F, ) -> Vec<R>
where F: Fn(&[T]) -> R + Send + Sync, R: Send + 'static,

Splits the slice in chunks of size chunks_size or less and maps the chunks in parallel across the provided task_pool. One task is spawned in the task pool for every chunk. Read more
Source§

fn par_splat_map<F, R>( &self, task_pool: &TaskPool, max_tasks: Option<usize>, f: F, ) -> Vec<R>
where F: Fn(&[T]) -> R + Send + Sync, R: Send + 'static,

Splits the slice into a maximum of max_tasks chunks, and maps the chunks in parallel across the provided task_pool. One task is spawned in the task pool for every chunk. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> TypeData for T
where T: 'static + Send + Sync + Clone,

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> Event for T
where T: Send + Sync + 'static,