From a8d31e464792ed94b7db489eaf89cda656b0a1d8 Mon Sep 17 00:00:00 2001 From: Hamza Date: Wed, 29 Sep 2021 11:42:44 +0500 Subject: [PATCH] impl PartialEq for `UseStateHandle` and `UseReducerHandle` --- packages/yew/src/functional/hooks/use_reducer.rs | 8 ++++++++ packages/yew/src/functional/hooks/use_state.rs | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/packages/yew/src/functional/hooks/use_reducer.rs b/packages/yew/src/functional/hooks/use_reducer.rs index 72effde3e43..27b44b03c82 100644 --- a/packages/yew/src/functional/hooks/use_reducer.rs +++ b/packages/yew/src/functional/hooks/use_reducer.rs @@ -184,3 +184,11 @@ impl fmt::Debug for UseReducerHandle { .finish() } } + +impl PartialEq for UseReducerHandle { + 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) + } +} diff --git a/packages/yew/src/functional/hooks/use_state.rs b/packages/yew/src/functional/hooks/use_state.rs index dd8c3a31ea0..af310a487aa 100644 --- a/packages/yew/src/functional/hooks/use_state.rs +++ b/packages/yew/src/functional/hooks/use_state.rs @@ -97,3 +97,11 @@ impl Clone for UseStateHandle { } } } + +impl PartialEq for UseStateHandle { + 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) + } +}