bevy/crates/bevy_ecs/src
JoJoJet 1efdbb7e3e Remove the SystemParamState trait and remove types like ResState (#6919)
Spiritual successor to #5205.
Actual successor to #6865.

# Objective

Currently, system params are defined using three traits: `SystemParam`, `ReadOnlySystemParam`, `SystemParamState`. The behavior for each param is specified by the `SystemParamState` trait, while `SystemParam` simply defers to the state.

Splitting the traits in this way makes it easier to implement within macros, but it increases the cognitive load. Worst of all, this approach requires each `MySystemParam` to have a public `MySystemParamState` type associated with it.

## Solution

* Merge the trait `SystemParamState` into `SystemParam`.
* Remove all trivial `SystemParam` state types. 
  * `OptionNonSendMutState<T>`: you will not be missed.

---

- [x] Fix/resolve the remaining test failure.

## Changelog

* Removed the trait `SystemParamState`, merging its functionality into `SystemParam`.

## Migration Guide

**Note**: this should replace the migration guide for #6865.
This is relative to Bevy 0.9, not main.

The traits `SystemParamState` and `SystemParamFetch` have been removed, and their functionality has been transferred to `SystemParam`.


```rust
// Before (0.9)
impl SystemParam for MyParam<'_, '_> {
    type State = MyParamState;
}
unsafe impl SystemParamState for MyParamState {
    fn init(world: &mut World, system_meta: &mut SystemMeta) -> Self { ... }
}
unsafe impl<'w, 's> SystemParamFetch<'w, 's> for MyParamState {
    type Item = MyParam<'w, 's>;
    fn get_param(&mut self, ...) -> Self::Item;
}
unsafe impl ReadOnlySystemParamFetch for MyParamState { }

// After (0.10)
unsafe impl SystemParam for MyParam<'_, '_> {
    type State = MyParamState;
    type Item<'w, 's> = MyParam<'w, 's>;
    fn init_state(world: &mut World, system_meta: &mut SystemMeta) -> Self::State { ... }
    fn get_param<'w, 's>(state: &mut Self::State, ...) -> Self::Item<'w, 's>;
}
unsafe impl ReadOnlySystemParam for MyParam<'_, '_> { }
```

The trait `ReadOnlySystemParamFetch` has been replaced with `ReadOnlySystemParam`.

```rust
// Before
unsafe impl ReadOnlySystemParamFetch for MyParamState {}

// After
unsafe impl ReadOnlySystemParam for MyParam<'_, '_> {}
```
2023-01-07 23:20:32 +00:00
..
entity Fix various typos (#7096) 2023-01-06 00:43:30 +00:00
query Fix various typos (#7096) 2023-01-06 00:43:30 +00:00
schedule Fix various typos (#7096) 2023-01-06 00:43:30 +00:00
storage Fix various typos (#7096) 2023-01-06 00:43:30 +00:00
system Remove the SystemParamState trait and remove types like ResState (#6919) 2023-01-07 23:20:32 +00:00
world Fix various typos (#7096) 2023-01-06 00:43:30 +00:00
archetype.rs Fix various typos (#7096) 2023-01-06 00:43:30 +00:00
bundle.rs Extend EntityLocation with TableId and TableRow (#6681) 2023-01-02 21:25:04 +00:00
change_detection.rs Update an outdated example for Mut::map_unchanged (#7115) 2023-01-06 23:24:25 +00:00
component.rs Document options for !Sync types for Component and Resources (#6864) 2022-12-11 18:34:13 +00:00
event.rs Rework manual event iterator so we can actually name the type (#5735) 2022-12-25 00:39:27 +00:00
lib.rs Fix clippy lints and failed test with Rust 1.66 (#6945) 2022-12-15 18:05:15 +00:00
reflect.rs Enable Constructing ReflectComponent/Resource (#6257) 2022-10-17 14:01:50 +00:00