macro_rules! Component {
    (
        ($($arg:tt)*)
        $vis:vis enum $name:ident
        $($token:tt)+
    ) => { ... };
    (
        ($($arg:tt)*)
        $vis:vis struct $name:ident
        $($token:tt)+
    ) => { ... };
}
Expand description

Macro attribute for deriving Component trait.

Accepts input in the following form:

($($(
    $param
),+ $(,)?)?)
$vis:vis $(enum | struct) $name:ident
$(
    <$generics>
    $($tokens_between_generics_and_where_clause:tt)*
    $(where $where_clause)?
)?
$( ; | { $($body:tt)* } )

where $param may be in any of following forms:

class = $Class:ident
alloc = $Allocator:ty

§Examples

§Non-generic component

macro_attr! {
    #[derive(Component!)]
    struct Item { /* ... */ }
}

// ...

let mut arena = Arena::new();
let id = arena.insert(|id| (Item { /* ... */ }, id));

§Generic component

macro_attr! {
    #[derive(Component!(class=ItemComponent))]
    struct Item<T> {
        context: T
    }
}

// ...

let mut arena_u8 = Arena::new();
let _ = arena_u8.insert(|id| (Item { context: 7u8 }, id));

let mut arena_u32 = Arena::new();
let _ = arena_u32.insert(|id| (Item { context: 7u32 }, id));