impl Deref for State<S>
Objective
State requires a kind of awkward state.0 to get the current state when we could just have it deref into it, given it is just a thin wrapper type.
Solution
impl Deref for State
The field in there should really be private too 🤔 Should we make that change here, or in a new PR?
The field in there should really be private too 🤔 Should we make that change here, or in a new PR?
I'll just make the change here because yeah, otherwise its a bit error prone for setting the next state.
It looks like your PR is a breaking change, but you didn't provide a migration guide.
Could you add some context on what users should update when this change get released in a new version of Bevy?
It will be used to help writing the migration guide for the version. Putting it after a ## Migration Guide will help it get automatically picked up by our tooling.
Idk if this is a win. It forces the "double star deref" for the State resource:
// before
fn system_1(state: Res<State<AppState>>) {
if state.0 == AppState::InGame {
info!("do thing");
}
}
// after
fn system(state: Res<State<AppState>>) {
if **state == AppState::InGame {
info!("do thing");
}
}
I think it's important to make the field private, but I would be fine with a getter instead.
Yeah I think a getter is preferable to double star