pub trait SpawnRelated: RelationshipTarget {
// Required methods
fn spawn<L>(list: L) -> SpawnRelatedBundle<Self::Relationship, L>
where L: SpawnableList<Self::Relationship>;
fn spawn_one<B>(bundle: B) -> SpawnOneRelated<Self::Relationship, B>
where B: Bundle;
}Expand description
RelationshipTarget methods that create a Bundle with a DynamicBundle::Effect that:
- Contains the
RelationshipTargetcomponent, pre-allocated with the necessary space for spawned entities. - Spawns an entity (or a list of entities) that relate to the entity the
Bundleis added to via theRelationshipTarget::Relationship.
Required Methods§
Sourcefn spawn<L>(list: L) -> SpawnRelatedBundle<Self::Relationship, L>where
L: SpawnableList<Self::Relationship>,
fn spawn<L>(list: L) -> SpawnRelatedBundle<Self::Relationship, L>where
L: SpawnableList<Self::Relationship>,
Returns a Bundle containing this RelationshipTarget component. It also spawns a SpawnableList of entities, each related to the bundle’s entity
via RelationshipTarget::Relationship. The RelationshipTarget (when possible) will pre-allocate space for the related entities.
See Spawn, SpawnIter, SpawnWith, WithRelated and WithOneRelated for usage examples.
Sourcefn spawn_one<B>(bundle: B) -> SpawnOneRelated<Self::Relationship, B>where
B: Bundle,
fn spawn_one<B>(bundle: B) -> SpawnOneRelated<Self::Relationship, B>where
B: Bundle,
Returns a Bundle containing this RelationshipTarget component. It also spawns a single entity containing Bundle that is related to the bundle’s entity
via RelationshipTarget::Relationship.
let mut world = World::new();
world.spawn((
Name::new("Root"),
Children::spawn_one(Name::new("Child")),
));Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.