pub trait WithChildren: Bundle + Sized {
    // Required method
    fn with_children(
        self,
        f: impl FnOnce(&mut SpawnChildBuilder<'_>)
    ) -> (Self, SpawnChildren);
}
Expand description

Trait used to attach children to an Entity using a Bundle.

§Example


#[derive(Component)]
struct Foo;

#[derive(Component)]
struct Bar;

let mut world = World::default();
world.spawn(Foo.with_children(|foo| {
   foo.spawn(Bar);
}));

Required Methods§

source

fn with_children( self, f: impl FnOnce(&mut SpawnChildBuilder<'_>) ) -> (Self, SpawnChildren)

Object Safety§

This trait is not object safe.

Implementors§