Skip to content

Ignore Default requirements when using unit structs in required components #18859

Open
@Freyja-moth

Description

@Freyja-moth

What problem does this solve or what need does it fill?

In order to add a unit struct to a components required components you need to implement Default on it, which is unneeded as unit structs only have one state.

What solution would you like?

Ignore the Default requirements for unit structs

#[derive(Component)]
pub struct Player;

#[derive(Component)]
#[require(Player)]
pub struct Character {
    health: u32,
}

What alternative(s) have you considered?

Deriving Default on all unit components which is a bit tedious.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useD-MacrosCode that generates Rust codeD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesS-Nominated-To-CloseA triage team member thinks this PR or issue should be closed out.X-ContentiousThere are nontrivial implications that should be thought through

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions