Skip to main content

RegisterComponent

Derive Macro RegisterComponent 

Source
#[derive(RegisterComponent)]
Expand description

Registers components that implement the Component trait.

This proc macro is used to automatically register structs that implement the Component trait with the [component::ComponentRegistry].

If the component trait is not implemented, it will generate a compile-time error.

ยงExample

use ui::Component;
use ui_macros::RegisterComponent;

#[derive(RegisterComponent)]
struct MyComponent;

impl Component for MyComponent {
    // Component implementation
}

This example will add MyComponent to the ComponentRegistry.