Instance

Struct Instance 

Source
pub struct Instance<T>(/* private fields */)
where
    T: Kind;
Expand description

Represents an Entity of Kind T.

Instance<Any> is functionally equivalent to an entity.

§Usage

An Instance<T> can be used to access entities in a “kind-safe” manner to improve safety and readability.

This type is designed to behave exactly like an Entity.

This means you may use it as a Query parameter, pass it to Commands to access InstanceCommands<T>, or store it as a type-safe reference to an Entity.

Note that an Instance<T> has 'static lifetime and does not contain any Component data. It only contains type information.

§Example


#[derive(Component)]
struct Apple;

#[derive(Component)]
struct Orange;

struct Fruit;

impl Kind for Fruit {
    type Filter = Or<(With<Apple>, With<Orange>)>;
}

#[derive(Resource, Deref, DerefMut)]
struct FruitBasket(Vec<Instance<Fruit>>);

fn collect_fruits(mut basket: ResMut<FruitBasket>, fruits: Query<Instance<Fruit>>) {
    for fruit in fruits.iter() {
        println!("{fruit:?}");
        basket.push(fruit);
    }
}

Implementations§

Source§

impl<T> Instance<T>
where T: Kind,

Source

pub const PLACEHOLDER: Instance<T>

Same as Entity::PLACEHOLDER, but for an Instance<T>.

Source

pub unsafe fn from_entity_unchecked(entity: Entity) -> Instance<T>

Creates a new instance of kind T from some Entity.

§Usage

This function is useful when you know an Entity is of a specific kind and you need an Instance<T> with no way to validate it.

See Instance::from_entity for a safer alternative.

§Safety

Assumes entity is a valid instance of kind T.

§Example

#[derive(Component)]
struct Apple;

fn init_apple(entity: Entity, commands: &mut Commands) -> Instance<Apple> {
    commands.entity(entity).insert(Apple);
    // SAFE: `entity` will be a valid instance of `Apple`.
    unsafe { Instance::from_entity_unchecked(entity) }
}
Source

pub fn entity(&self) -> Entity

Returns the Entity of this instance.

Source

pub fn cast_into<U>(self) -> Instance<U>
where U: Kind, T: CastInto<U>,

Converts this instance into an instance of another kind Kind U.

§Usage

A kind T is safety convertible to another kind U if T implements CastInto<U>.

Source

pub fn cast_into_any(self) -> Instance<Any>

Converts this instance into an instance of Kind Any.

§Usage

Any Instance<T> can be safely cast into an Instance<Any> using this function.

Source

pub unsafe fn cast_into_unchecked<U>(self) -> Instance<U>
where U: Kind,

Converts this instance into an instance of another kind Kind U without any validation.

§Usage

This function is useful when you know an Instance<T> is convertible to a specific type and you need an Instance<U> with no way to validate it.

Always prefer to explicitly declare safe casts with the CastInto trait and use Instance::cast_into.

§Safety

Assumes this instance is also a valid Instance<U>.

Source

pub unsafe fn as_entity_mut(&mut self) -> &mut Entity

👎Deprecated: use Instance::<T>::from_entity_unchecked instead

Returns a mutable reference to the internal Entity of this Instance.

§Safety

You are responsible to ensure the entity is still a valid instance of Kind T.

Source§

impl<T> Instance<T>
where T: Component,

Source

pub fn from_entity(entity: EntityRef<'_>) -> Option<Instance<T>>

Creates a new instance of kind T from some EntityRef if the entity has a Component of type T.

Methods from Deref<Target = Entity>§

Trait Implementations§

Source§

impl<T> AsRef<Instance<T>> for InstanceMut<'_, T>
where T: Component,

Source§

fn as_ref(&self) -> &Instance<T>

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

impl<T> AsRef<Instance<T>> for InstanceRef<'_, T>
where T: Component,

Source§

fn as_ref(&self) -> &Instance<T>

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

impl<T> Borrow<Entity> for Instance<T>
where T: Kind,

Source§

fn borrow(&self) -> &Entity

Immutably borrows from an owned value. Read more
Source§

impl<T> Clone for Instance<T>
where T: Kind,

Source§

fn clone(&self) -> Instance<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<T> ContainsEntity for Instance<T>
where T: Kind,

Source§

fn entity(&self) -> Entity

Returns the contained entity.
Source§

impl<T> Debug for Instance<T>
where T: Kind,

Source§

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

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

impl<T> Deref for Instance<T>
where T: Kind,

Source§

type Target = Entity

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<Instance<T> as Deref>::Target

Dereferences the value.
Source§

impl<T> Display for Instance<T>
where T: Kind,

Source§

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

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

impl<'a, T> From<&InstanceCommands<'a, T>> for Instance<T>
where T: Kind,

Source§

fn from(commands: &InstanceCommands<'a, T>) -> Instance<T>

Converts to this type from the input type.
Source§

impl<T> From<&InstanceMut<'_, T>> for Instance<T>
where T: Component,

Source§

fn from(item: &InstanceMut<'_, T>) -> Instance<T>

Converts to this type from the input type.
Source§

impl<T> From<&InstanceRef<'_, T>> for Instance<T>
where T: Component,

Source§

fn from(item: &InstanceRef<'_, T>) -> Instance<T>

Converts to this type from the input type.
Source§

impl From<Entity> for Instance<Any>

Source§

fn from(entity: Entity) -> Instance<Any>

Converts to this type from the input type.
Source§

impl<T> From<Instance<T>> for Entity
where T: Kind,

Source§

fn from(instance: Instance<T>) -> Entity

Converts to this type from the input type.
Source§

impl<'a, T> From<InstanceCommands<'a, T>> for Instance<T>
where T: Kind,

Source§

fn from(commands: InstanceCommands<'a, T>) -> Instance<T>

Converts to this type from the input type.
Source§

impl<T> From<InstanceMut<'_, T>> for Instance<T>
where T: Component,

Source§

fn from(item: InstanceMut<'_, T>) -> Instance<T>

Converts to this type from the input type.
Source§

impl<T> From<InstanceRef<'_, T>> for Instance<T>
where T: Component,

Source§

fn from(item: InstanceRef<'_, T>) -> Instance<T>

Converts to this type from the input type.
Source§

impl<T> From<Object<'_, '_, '_, T>> for Instance<T>
where T: Kind,

Source§

fn from(object: Object<'_, '_, '_, T>) -> Instance<T>

Converts to this type from the input type.
Source§

impl<T> From<ObjectRef<'_, '_, '_, T>> for Instance<T>
where T: Kind,

Source§

fn from(object: ObjectRef<'_, '_, '_, T>) -> Instance<T>

Converts to this type from the input type.
Source§

impl<T> From<ObjectWorldRef<'_, T>> for Instance<T>
where T: Kind,

Source§

fn from(object: ObjectWorldRef<'_, T>) -> Instance<T>

Converts to this type from the input type.
Source§

impl<T> FromReflect for Instance<T>
where T: Kind + TypePath, Instance<T>: Any + Send + Sync,

Source§

fn from_reflect(reflect: &(dyn PartialReflect + 'static)) -> Option<Instance<T>>

Constructs a concrete instance of Self from a reflected value.
Source§

fn take_from_reflect( reflect: Box<dyn PartialReflect>, ) -> Result<Self, Box<dyn PartialReflect>>

Attempts to downcast the given value to Self using, constructing the value using from_reflect if that fails. Read more
Source§

impl<T> GetTypeRegistration for Instance<T>
where T: Kind + TypePath, Instance<T>: Any + Send + Sync,

Source§

fn get_type_registration() -> TypeRegistration

Returns the default TypeRegistration for this type.
Source§

fn register_type_dependencies(registry: &mut TypeRegistry)

Registers other types needed by this type. Read more
Source§

impl<T> Hash for Instance<T>
where T: Kind,

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> MapEntities for Instance<T>
where T: Kind,

Source§

fn map_entities<M>(&mut self, entity_mapper: &mut M)
where M: EntityMapper,

Updates all Entity references stored inside using entity_mapper. Read more
Source§

impl<T> Ord for Instance<T>
where T: Kind,

Source§

fn cmp(&self, other: &Instance<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<T> PartialEq<Entity> for Instance<T>
where T: Kind,

Source§

fn eq(&self, other: &Entity) -> 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<T> PartialEq<Instance<T>> for Entity
where T: Kind,

Source§

fn eq(&self, other: &Instance<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<T> PartialEq<Instance<T>> for Object<'_, '_, '_, T>
where T: Kind,

Source§

fn eq(&self, other: &Instance<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<T> PartialEq<Instance<T>> for ObjectWorldRef<'_, T>
where T: Kind,

Source§

fn eq(&self, other: &Instance<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<T, U> PartialEq<Instance<U>> for Instance<T>
where T: Kind, U: Kind,

Source§

fn eq(&self, other: &Instance<U>) -> 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<T> PartialEq<Object<'_, '_, '_, T>> for Instance<T>
where T: Kind,

Source§

fn eq(&self, other: &Object<'_, '_, '_, 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<T> PartialEq<ObjectWorldRef<'_, T>> for Instance<T>
where T: Kind,

Source§

fn eq(&self, other: &ObjectWorldRef<'_, 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<T> PartialOrd for Instance<T>
where T: Kind,

Source§

fn partial_cmp(&self, other: &Instance<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<T> PartialReflect for Instance<T>
where T: Kind + TypePath, Instance<T>: Any + Send + Sync,

Source§

fn get_represented_type_info(&self) -> Option<&'static TypeInfo>

Returns the TypeInfo of the type represented by this value. Read more
Source§

fn try_apply( &mut self, value: &(dyn PartialReflect + 'static), ) -> Result<(), ApplyError>

Tries to apply a reflected value to this value. Read more
Source§

fn reflect_kind(&self) -> ReflectKind

Returns a zero-sized enumeration of “kinds” of type. Read more
Source§

fn reflect_ref(&self) -> ReflectRef<'_>

Returns an immutable enumeration of “kinds” of type. Read more
Source§

fn reflect_mut(&mut self) -> ReflectMut<'_>

Returns a mutable enumeration of “kinds” of type. Read more
Source§

fn reflect_owned(self: Box<Instance<T>>) -> ReflectOwned

Returns an owned enumeration of “kinds” of type. Read more
Source§

fn try_into_reflect( self: Box<Instance<T>>, ) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>

Attempts to cast this type to a boxed, fully-reflected value.
Source§

fn try_as_reflect(&self) -> Option<&(dyn Reflect + 'static)>

Attempts to cast this type to a fully-reflected value.
Source§

fn try_as_reflect_mut(&mut self) -> Option<&mut (dyn Reflect + 'static)>

Attempts to cast this type to a mutable, fully-reflected value.
Source§

fn into_partial_reflect(self: Box<Instance<T>>) -> Box<dyn PartialReflect>

Casts this type to a boxed, reflected value. Read more
Source§

fn as_partial_reflect(&self) -> &(dyn PartialReflect + 'static)

Casts this type to a reflected value. Read more
Source§

fn as_partial_reflect_mut(&mut self) -> &mut (dyn PartialReflect + 'static)

Casts this type to a mutable, reflected value. Read more
Source§

fn reflect_partial_eq( &self, value: &(dyn PartialReflect + 'static), ) -> Option<bool>

Returns a “partial equality” comparison result. Read more
Source§

fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>

Attempts to clone Self using reflection. Read more
Source§

fn apply(&mut self, value: &(dyn PartialReflect + 'static))

Applies a reflected value to this value. Read more
Source§

fn to_dynamic(&self) -> Box<dyn PartialReflect>

Converts this reflected value into its dynamic representation based on its kind. Read more
Source§

fn reflect_clone_and_take<T>(&self) -> Result<T, ReflectCloneError>
where T: 'static, Self: Sized + TypePath,

For a type implementing PartialReflect, combines reflect_clone and take in a useful fashion, automatically constructing an appropriate ReflectCloneError if the downcast fails. Read more
Source§

fn reflect_hash(&self) -> Option<u64>

Returns a hash of the value (which includes the type). Read more
Source§

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

Debug formatter for the value. Read more
Source§

fn is_dynamic(&self) -> bool

Indicates whether or not this type is a dynamic type. Read more
Source§

impl<T> QueryData for Instance<T>
where T: Kind,

Source§

const IS_READ_ONLY: bool = <Entity as QueryData>::IS_READ_ONLY

True if this query is read-only and may not perform mutable access.
Source§

const IS_ARCHETYPAL: bool = <Entity as QueryData>::IS_ARCHETYPAL

Returns true if (and only if) this query data relies strictly on archetypes to limit which entities are accessed by the Query. Read more
Source§

type ReadOnly = Instance<T>

The read-only variant of this QueryData, which satisfies the ReadOnlyQueryData trait.
Source§

type Item<'w, 's> = Instance<T>

The item returned by this WorldQuery This will be the data retrieved by the query, and is visible to the end user when calling e.g. Query<Self>::get.
Source§

fn shrink<'wlong, 'wshort, 's>( item: <Instance<T> as QueryData>::Item<'wlong, 's>, ) -> <Instance<T> as QueryData>::Item<'wshort, 's>
where 'wlong: 'wshort,

This function manually implements subtyping for the query items.
Source§

unsafe fn fetch<'w, 's>( _state: &'s <Instance<T> as WorldQuery>::State, _fetch: &mut <Instance<T> as WorldQuery>::Fetch<'w>, entity: Entity, _table_row: TableRow, ) -> Option<<Instance<T> as QueryData>::Item<'w, 's>>

Fetch 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 an entity in the current archetype. Accesses components registered in WorldQuery::update_component_access. Read more
Source§

fn iter_access( _state: &<Instance<T> as WorldQuery>::State, ) -> impl Iterator<Item = EcsAccessType<'_>>

Returns an iterator over the access needed by QueryData::fetch. Access conflicts are usually checked in WorldQuery::update_component_access, but in certain cases this method can be useful to implement a way of checking for access conflicts in a non-allocating way.
Source§

fn provide_extra_access( _state: &mut Self::State, _access: &mut Access, _available_access: &Access, )

Offers additional access above what we requested in update_component_access. Implementations may add additional access that is a subset of available_access and does not conflict with anything in access, and must update access to include that access. Read more
Source§

impl<T> Reflect for Instance<T>
where T: Kind + TypePath, Instance<T>: Any + Send + Sync,

Source§

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

Returns the value as a Box<dyn Any>. Read more
Source§

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

Returns the value as a &dyn Any. Read more
Source§

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

Returns the value as a &mut dyn Any. Read more
Source§

fn into_reflect(self: Box<Instance<T>>) -> Box<dyn Reflect>

Casts this type to a boxed, fully-reflected value.
Source§

fn as_reflect(&self) -> &(dyn Reflect + 'static)

Casts this type to a fully-reflected value.
Source§

fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)

Casts this type to a mutable, fully-reflected value.
Source§

fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>

Performs a type-checked assignment of a reflected value to this value. Read more
Source§

impl<T> RelationshipSourceCollection for Instance<T>
where T: Kind,

Source§

type SourceIter<'a> = <Entity as RelationshipSourceCollection>::SourceIter<'a>

The type of iterator returned by the iter method. Read more
Source§

fn new() -> Instance<T>

Creates a new empty instance.
Source§

fn with_capacity(_capacity: usize) -> Instance<T>

Returns an instance with the given pre-allocated entity capacity. Read more
Source§

fn reserve(&mut self, additional: usize)

Reserves capacity for at least additional more entities to be inserted. Read more
Source§

fn add(&mut self, entity: Entity) -> bool

Adds the given entity to the collection. Read more
Source§

fn remove(&mut self, entity: Entity) -> bool

Removes the given entity from the collection. Read more
Source§

fn iter(&self) -> <Instance<T> as RelationshipSourceCollection>::SourceIter<'_>

Iterates all entities in the collection.
Source§

fn len(&self) -> usize

Returns the current length of the collection.
Source§

fn clear(&mut self)

Clears the collection.
Source§

fn shrink_to_fit(&mut self)

Attempts to save memory by shrinking the capacity to fit the current length. Read more
Source§

fn extend_from_iter(&mut self, entities: impl IntoIterator<Item = Entity>)

Add multiple entities to collection at once. Read more
Source§

fn is_empty(&self) -> bool

Returns true if the collection contains no entities.
Source§

fn source_to_remove_before_add(&self) -> Option<Entity>

For one-to-one relationships, returns the entity that should be removed before adding a new one. Returns None for one-to-many relationships or when no entity needs to be removed.
Source§

impl<T> TupleStruct for Instance<T>
where T: Kind + TypePath, Instance<T>: Any + Send + Sync,

Source§

fn field(&self, index: usize) -> Option<&(dyn PartialReflect + 'static)>

Returns a reference to the value of the field with index index as a &dyn Reflect.
Source§

fn field_mut( &mut self, index: usize, ) -> Option<&mut (dyn PartialReflect + 'static)>

Returns a mutable reference to the value of the field with index index as a &mut dyn Reflect.
Source§

fn field_len(&self) -> usize

Returns the number of fields in the tuple struct.
Source§

fn iter_fields(&self) -> TupleStructFieldIter<'_>

Returns an iterator over the values of the tuple struct’s fields.
Source§

fn to_dynamic_tuple_struct(&self) -> DynamicTupleStruct

Creates a new DynamicTupleStruct from this tuple struct.
Source§

fn get_represented_tuple_struct_info(&self) -> Option<&'static TupleStructInfo>

Will return None if TypeInfo is not available.
Source§

impl<T> TypePath for Instance<T>
where T: Kind + TypePath, Instance<T>: Any + Send + Sync,

Source§

fn type_path() -> &'static str

Returns the fully qualified path of the underlying type. Read more
Source§

fn short_type_path() -> &'static str

Returns a short, pretty-print enabled path to the type. Read more
Source§

fn type_ident() -> Option<&'static str>

Returns the name of the type, or None if it is anonymous. Read more
Source§

fn crate_name() -> Option<&'static str>

Returns the name of the crate the type is in, or None if it is anonymous. Read more
Source§

fn module_path() -> Option<&'static str>

Returns the path to the module the type is in, or None if it is anonymous. Read more
Source§

impl<T> Typed for Instance<T>
where T: Kind + TypePath, Instance<T>: Any + Send + Sync,

Source§

fn type_info() -> &'static TypeInfo

Returns the compile-time info for the underlying type.
Source§

impl<T> WorldQuery for Instance<T>
where T: Kind,

Source§

const IS_DENSE: bool = <T::Filter as WorldQuery>::IS_DENSE

Returns true if (and only if) every table of every archetype matched by this fetch contains all of the matched components. Read more
Source§

type Fetch<'a> = <<T as Kind>::Filter as WorldQuery>::Fetch<'a>

Per archetype/table state retrieved by this WorldQuery to compute Self::Item for each entity.
Source§

type State = <<T as Kind>::Filter as WorldQuery>::State

State used to construct a 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_fetch<'wlong, 'wshort>( fetch: <Instance<T> as WorldQuery>::Fetch<'wlong>, ) -> <Instance<T> as WorldQuery>::Fetch<'wshort>
where 'wlong: 'wshort,

This function manually implements subtyping for the query fetches.
Source§

unsafe fn init_fetch<'w>( world: UnsafeWorldCell<'w>, state: &<Instance<T> as WorldQuery>::State, last_change_tick: Tick, change_tick: Tick, ) -> <Instance<T> as WorldQuery>::Fetch<'w>

Creates a new instance of Self::Fetch, by combining data from the World with the cached Self::State. Readonly accesses resources registered in WorldQuery::update_component_access. Read more
Source§

unsafe fn set_archetype<'w>( fetch: &mut <Instance<T> as WorldQuery>::Fetch<'w>, state: &<Instance<T> as WorldQuery>::State, archetype: &'w Archetype, table: &'w Table, )

Adjusts internal state to account for the next Archetype. This will always be called on archetypes that match this WorldQuery. Read more
Source§

unsafe fn set_table<'w>( fetch: &mut <Instance<T> as WorldQuery>::Fetch<'w>, state: &<Instance<T> as WorldQuery>::State, table: &'w Table, )

Adjusts internal state to account for the next Table. This will always be called on tables that match this WorldQuery. Read more
Source§

fn update_component_access( state: &<Instance<T> as WorldQuery>::State, access: &mut FilteredAccess, )

Adds any component accesses used by this WorldQuery to access. Read more
Source§

fn get_state( components: &Components, ) -> Option<<Instance<T> as WorldQuery>::State>

Attempts to initialize a State for this WorldQuery type using read-only access to Components.
Source§

fn init_state(world: &mut World) -> <Instance<T> as WorldQuery>::State

Creates and initializes a State for this WorldQuery type.
Source§

fn matches_component_set( state: &<Instance<T> as WorldQuery>::State, set_contains_id: &impl Fn(ComponentId) -> bool, ) -> bool

Returns true if this query matches a set of components. Otherwise, returns false. Read more
Source§

impl<T> Copy for Instance<T>
where T: Kind,

Source§

impl<T> Eq for Instance<T>
where T: Kind,

Source§

impl<T> ReadOnlyQueryData for Instance<T>
where T: Kind,

Auto Trait Implementations§

§

impl<T> Freeze for Instance<T>

§

impl<T> RefUnwindSafe for Instance<T>
where T: RefUnwindSafe,

§

impl<T> Send for Instance<T>

§

impl<T> Sync for Instance<T>

§

impl<T> Unpin for Instance<T>
where T: Unpin,

§

impl<T> UnwindSafe for Instance<T>
where 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<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>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

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

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

Converts &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> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

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

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<T> DynHash for T
where T: DynEq + Hash,

Source§

fn dyn_hash(&self, state: &mut dyn Hasher)

Feeds this value into the given Hasher.
Source§

impl<T> DynamicTypePath for T
where T: TypePath,

Source§

impl<T> DynamicTyped for T
where T: Typed,

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> GetPath for T
where T: Reflect + ?Sized,

Source§

fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>

Returns a reference to the value specified by path. Read more
Source§

fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>

Returns a mutable reference to the value specified by path. Read more
Source§

fn path<'p, T>( &self, path: impl ReflectPath<'p>, ) -> Result<&T, ReflectPathError<'p>>
where T: Reflect,

Returns a statically typed reference to the value specified by path. Read more
Source§

fn path_mut<'p, T>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut T, ReflectPathError<'p>>
where T: Reflect,

Returns a statically typed mutable reference to the value specified by path. Read more
Source§

impl<S> GetTupleStructField for S
where S: TupleStruct,

Source§

fn get_field<T>(&self, index: usize) -> Option<&T>
where T: Reflect,

Returns a reference to the value of the field with index index, downcast to T.
Source§

fn get_field_mut<T>(&mut self, index: usize) -> Option<&mut T>
where T: Reflect,

Returns a mutable reference to the value of the field with index index, downcast to T.
Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

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

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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§

fn clone_type_data(&self) -> Box<dyn TypeData>

Creates a type-erased clone of this value.
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> ConditionalSend for T
where T: Send,

Source§

impl<T> Reflectable for T

Source§

impl<T> Registerable for T

Source§

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

Source§

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

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,