Skip to content

Commit

Permalink
Getter instead of deref
Browse files Browse the repository at this point in the history
  • Loading branch information
Aceeri committed Mar 23, 2023
1 parent cbbb81d commit 42d8e34
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/schedule/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ pub mod common_conditions {
/// assert_eq!(world.resource::<Counter>().0, 0);
/// ```
pub fn in_state<S: States>(state: S) -> impl FnMut(Res<State<S>>) -> bool + Clone {
move |current_state: Res<State<S>>| current_state.0 == state
move |current_state: Res<State<S>>| *current_state.get() == state
}

/// Generates a [`Condition`](super::Condition)-satisfying closure that returns `true`
Expand Down Expand Up @@ -751,7 +751,7 @@ pub mod common_conditions {
state: S,
) -> impl FnMut(Option<Res<State<S>>>) -> bool + Clone {
move |current_state: Option<Res<State<S>>>| match current_state {
Some(current_state) => current_state.0 == state,
Some(current_state) => *current_state.get() == state,
None => false,
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_ecs/src/schedule/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ pub struct OnUpdate<S: States>(pub S);
#[derive(Resource, Default, Debug)]
pub struct State<S: States>(S);

impl<S: States> std::ops::Deref for State<S> {
type Target = S;
fn deref(&self) -> &Self::Target {
impl<S: States> State<S> {
/// Get the current state.
pub fn get(&self) -> &S {
&self.0
}
}
Expand Down

0 comments on commit 42d8e34

Please sign in to comment.