bevy/crates
Wuketuke baca78b565 Required components accept const values (#16720) (#18309)
# Objective

Const values should be more ergonomic to insert, since this is too
verbose
``` rust
#[derive(Component)]
#[require(
    LockedAxes(||LockedAxes::ROTATION_LOCKED),
)]
pub struct CharacterController;
```
instead, users can now abbreviate that nonsense like this
``` rust
#[derive(Component)]
#[require(
    LockedAxes = ROTATION_LOCKED),
)]
pub struct CharacterController;
```
it also works for enum labels.
I chose to omit the type, since were trying to reduce typing here. The
alternative would have been this:
```rust
#[require(
    LockedAxes = LockedAxes::ROTATION_LOCKED),
)]
```
This of course has its disadvantages, since the const has to be
associated, but the old closure method is still possible, so I dont
think its a problem.
- Fixes #16720

## Testing

I added one new test in the docs, which also explain the new change. I
also saw that the docs for the required components on line 165 was
missing an assertion, so I added it back in

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2025-03-24 00:09:29 +01:00
..
bevy_a11y Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_animation Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_app Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_asset Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_audio Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_color Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_core_pipeline Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_derive Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_dev_tools Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_diagnostic Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_dylib enable std when building bevy_dylib (#18405) 2025-03-19 08:03:12 +01:00
bevy_ecs Required components accept const values (#16720) (#18309) 2025-03-24 00:09:29 +01:00
bevy_encase_derive Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_gilrs Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_gizmos Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_gltf Gltf handle missing bindposes (#18419) 2025-03-24 00:09:29 +01:00
bevy_image Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_input Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_input_focus Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_internal Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_log Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_macro_utils Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_math Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_mesh Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_mikktspace Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_pbr Fix specialize_shadows system ordering (#18412) 2025-03-19 21:36:18 +01:00
bevy_picking Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_platform_support Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_ptr Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_reflect Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_remote Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_render Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_scene Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_sprite Fix unecessary specialization checks for apps with many materials (#18410) 2025-03-19 21:36:18 +01:00
bevy_state Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_tasks Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_text Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_time Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_transform Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_ui Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_utils Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_window Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_winit Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00