Consider letting `SystemState::get_manual` take an immutable reference to self? Similar to `QueryState::get_manual` take an immutable reference
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
> Is there a way we can make `SystemStare::get_manual` take an immutable reference to self? Similar to `QueryState::get_manual`.
At first glance, this seems very difficult to generalize. We'd have to change `SystemParam::get_param` to take an immutable refence to the state, which would break params that need to modify their state such as `Commands` or `Local` or `EventReader`.
One way of doing this would be to add a new trait for `SystemParam`s that do not mutably access their state in `get_param`, and then add `SystemState::get_readonly` which is constrained to using this trait. This would allow *most* `SystemParam`s to be used with a read-only `SystemState`, while excluding the param types that don't make sense. I am not exactly sure what this would look like, though.
_Originally posted by @JoJoJet in https://github.com/bevyengine/bevy/issues/7084#issuecomment-1385470283_
Contributor guide
Assessment
This issue has not been assessed yet.