component

Attribute Macro component 

Source
#[component]
Expand description

Marks a struct as a component

Automatically derives:

  • Debug - Required by Component trait
  • Clone - Useful for component copying
  • PartialEq - Useful for testing and comparison

Also adds #[allow(dead_code)] to prevent warnings on unused fields.

§Example

#[component]
struct Position {
    x: f32,
    y: f32,
}

// Expands to:
#[derive(Debug, Clone, PartialEq)]
#[allow(dead_code)]
struct Position {
    x: f32,
    y: f32,
}

§Requirements

Component types must be:

  • Simple structs (no enums or unions)
  • All fields must implement Debug, Clone, PartialEq