WithOneRelated

Struct WithOneRelated 

Source
pub struct WithOneRelated(pub Entity);
Expand description

A wrapper over an Entity indicating that an entity should be added. This is intended to be used for hierarchical spawning via traits like SpawnableList and SpawnRelated.

Unlike WithRelated this only adds one entity.

Also see the children and related macros that abstract over the Spawn API.

let mut world = World::new();

let child1 = world.spawn(Name::new("Child1")).id();

world.spawn((
    Name::new("Root"),
    Children::spawn((
        // This adds the already existing entity as a child of Root.
        WithOneRelated(child1),
    )),
));

Tuple Fields§

§0: Entity

Trait Implementations§

Source§

impl<R: Relationship> SpawnableList<R> for WithOneRelated

Source§

fn spawn(this: MovingPtr<'_, Self>, world: &mut World, entity: Entity)

Spawn this list of changes in a given World and relative to a given Entity. This is generally used for spawning “related” entities, such as children.
Source§

fn size_hint(&self) -> usize

Returns a size hint, which is used to reserve space for this list in a RelationshipTarget. This should be less than or equal to the actual size of the list. When in doubt, just use 0.

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoResult<T> for T

Source§

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

Converts this type into the system output type.
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> ConditionalSend for T
where T: Send,