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 c81f1fa commit a68126a
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 @@ -304,7 +304,7 @@ pub mod common_conditions {
///
/// The condition will panic if the resource does not exist.
pub fn in_state<S: States>(state: S) -> impl FnMut(Res<State<S>>) -> bool {
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 All @@ -315,7 +315,7 @@ pub mod common_conditions {
state: S,
) -> impl FnMut(Option<Res<State<S>>>) -> bool {
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 @@ -73,9 +73,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 a68126a

Please sign in to comment.