Skip to main content

Bundle

Derive Macro Bundle 

Source
#[derive(Bundle)]
Available on crate feature macros only.
Expand description

Implement Bundle for a struct

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

ยงExample

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

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