Derive Macro hecs::Bundle

source ·
#[derive(Bundle)]
Expand description

Implement Bundle for a struct

Bundles can be passed directly to World::spawn and World::insert, and obtained from World::remove. Can be convenient when combined with other derives like serde::Deserialize.

Example

#[derive(Bundle)]
struct Foo {
    x: i32,
    y: char,
}

let mut world = World::new();
let e = world.spawn(Foo { x: 42, y: 'a' });
assert_eq!(*world.get::<&i32>(e).unwrap(), 42);