Skip to content

Commit

Permalink
impl PartialEq for UseStateHandle and UseReducerHandle
Browse files Browse the repository at this point in the history
  • Loading branch information
ranile committed Sep 29, 2021
1 parent 4ab710c commit a388536
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/yew/src/functional/hooks/use_reducer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,11 @@ impl<T: fmt::Debug, V> fmt::Debug for UseReducerHandle<T, V> {
.finish()
}
}

impl<State, Action> PartialEq for UseReducerHandle<State, Action> {
fn eq(&self, other: &Self) -> bool {
// if the value is the same pointer
// then we can assume that that setter is also the same thing
Rc::ptr_eq(&self.value, &other.value)
}
}
8 changes: 8 additions & 0 deletions packages/yew/src/functional/hooks/use_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,11 @@ impl<T> Clone for UseStateHandle<T> {
}
}
}

impl<T> PartialEq for UseStateHandle<T> {
fn eq(&self, other: &Self) -> bool {
// if the value is the same pointer
// then we can assume that that setter is also the same thing
Rc::ptr_eq(&self.value, &other.value)
}
}

0 comments on commit a388536

Please sign in to comment.