bevy/crates/bevy_ecs/src
JoJoJet c43295af80 Simplify design for *Labels (#4957)
# Objective

- Closes #4954 
- Reduce the complexity of the `{System, App, *}Label` APIs.

## Solution

For the sake of brevity I will only refer to `SystemLabel`, but everything applies to all of the other label types as well.

- Add `SystemLabelId`, a lightweight, `copy` struct.
- Convert custom types into `SystemLabelId` using the trait `SystemLabel`.

## Changelog

- String literals implement `SystemLabel` for now, but this should be changed with #4409 .

## Migration Guide

- Any previous use of `Box<dyn SystemLabel>` should be replaced with `SystemLabelId`.
- `AsSystemLabel` trait has been modified.
    - No more output generics.
    - Method `as_system_label` now returns `SystemLabelId`, removing an unnecessary level of indirection.
- If you *need* a label that is determined at runtime, you can use `Box::leak`. Not recommended.

## Questions for later

* Should we generate a `Debug` impl along with `#[derive(*Label)]`?
* Should we rename `as_str()`?
* Should we remove the extra derives (such as `Hash`) from builtin `*Label` types?
* Should we automatically derive types like `Clone, Copy, PartialEq, Eq`?
* More-ergonomic comparisons between `Label` and `LabelId`.
* Move `Dyn{Eq, Hash,Clone}` somewhere else.
* Some API to make interning dynamic labels easier.
* Optimize string representation
    * Empty string for unit structs -- no debug info but faster comparisons
    * Don't show enum types -- same tradeoffs as asbove.
2022-07-14 18:23:01 +00:00
..
entity Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
query Add ExactSizeIterator implementation for QueryCombinatonIter (#5148) 2022-07-13 16:08:48 +00:00
schedule Simplify design for *Labels (#4957) 2022-07-14 18:23:01 +00:00
storage Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
system Simplify design for *Labels (#4957) 2022-07-14 18:23:01 +00:00
world Fix typo in Word::get_by_id docs (#5246) 2022-07-07 15:25:17 +00:00
archetype.rs add more SAFETY comments and lint for missing ones in bevy_ecs (#4835) 2022-07-04 14:44:24 +00:00
bundle.rs add more SAFETY comments and lint for missing ones in bevy_ecs (#4835) 2022-07-04 14:44:24 +00:00
change_detection.rs Add reflection for resources (#5175) 2022-07-04 13:04:20 +00:00
component.rs add more SAFETY comments and lint for missing ones in bevy_ecs (#4835) 2022-07-04 14:44:24 +00:00
event.rs Document exotic patterns for Commands and Events (#4840) 2022-07-13 14:40:52 +00:00
lib.rs add more SAFETY comments and lint for missing ones in bevy_ecs (#4835) 2022-07-04 14:44:24 +00:00
reflect.rs Add apply_or_insert functions to reflected component and resources (#5201) 2022-07-11 14:11:24 +00:00