Struct components_arena::ComponentClassToken[][src]

pub struct ComponentClassToken<C: ComponentClass> { /* fields omitted */ }
Expand description

Component class static shared data.

In the no-no_std environment it can be stored inside static ComponentClassMutex:

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

static MY_COMPONENT: ComponentClassMutex<MyComponent> = ComponentClassMutex::new();

// ...

let mut arena = Arena::new(&mut MY_COMPONENT.lock().unwrap());
let id = arena.insert(|id| (MyComponent { /* ... */ }, id));

In the no_std environment a custom solution should be used to store ComponentClassToken.

Implementations

Creates components shared data storage on first call for every component type C. All subsequent calls will return None.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.