Skip to content

Commit 42d8e34

Browse files
committed
Getter instead of deref
1 parent cbbb81d commit 42d8e34

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

crates/bevy_ecs/src/schedule/condition.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ pub mod common_conditions {
692692
/// assert_eq!(world.resource::<Counter>().0, 0);
693693
/// ```
694694
pub fn in_state<S: States>(state: S) -> impl FnMut(Res<State<S>>) -> bool + Clone {
695-
move |current_state: Res<State<S>>| current_state.0 == state
695+
move |current_state: Res<State<S>>| *current_state.get() == state
696696
}
697697

698698
/// Generates a [`Condition`](super::Condition)-satisfying closure that returns `true`
@@ -751,7 +751,7 @@ pub mod common_conditions {
751751
state: S,
752752
) -> impl FnMut(Option<Res<State<S>>>) -> bool + Clone {
753753
move |current_state: Option<Res<State<S>>>| match current_state {
754-
Some(current_state) => current_state.0 == state,
754+
Some(current_state) => *current_state.get() == state,
755755
None => false,
756756
}
757757
}

crates/bevy_ecs/src/schedule/state.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ pub struct OnUpdate<S: States>(pub S);
8585
#[derive(Resource, Default, Debug)]
8686
pub struct State<S: States>(S);
8787

88-
impl<S: States> std::ops::Deref for State<S> {
89-
type Target = S;
90-
fn deref(&self) -> &Self::Target {
88+
impl<S: States> State<S> {
89+
/// Get the current state.
90+
pub fn get(&self) -> &S {
9191
&self.0
9292
}
9393
}

0 commit comments

Comments
 (0)