Skip to content

Allow implicit Into for BSN enum field values#24621

Open
bugsweeper wants to merge 1 commit into
bevyengine:mainfrom
bugsweeper:fix/bsn-enum-field-into
Open

Allow implicit Into for BSN enum field values#24621
bugsweeper wants to merge 1 commit into
bevyengine:mainfrom
bugsweeper:fix/bsn-enum-field-into

Conversation

@bugsweeper

Copy link
Copy Markdown
Contributor

Objective

Solution

  • Route enum variant field values through the normal BsnValue token generation path.
  • Make BsnValue::Type emit (...).into() when used as a value.
  • Preserve existing enum component patching behavior, where entries like Foo::Bar { x: 1 } and Foo::Qux patch the enum component itself.

Testing

  • cargo fmt --check -p bevy_scene -p bevy_scene_macros
  • cargo test -p bevy_scene_macros enum_variant_field_values_use_implicit_into
  • cargo test -p bevy_scene enum_variant_field_values_use_implicit_into
  • cargo test -p bevy_scene enum_patching

Showcase

TextFont {
    font_size: TextSize::Large,
}

@kfc35 kfc35 added A-Scenes Composing and serializing ECS objects D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward D-Macros Code that generates Rust code C-Bug An unexpected or incorrect behavior labels Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Scenes Composing and serializing ECS objects C-Bug An unexpected or incorrect behavior D-Macros Code that generates Rust code D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow BSN users to directly write enums as fields

2 participants