Skip to content

Commit a8d31e4

Browse files
committed
impl PartialEq for UseStateHandle and UseReducerHandle
1 parent 4ab710c commit a8d31e4

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

packages/yew/src/functional/hooks/use_reducer.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,11 @@ impl<T: fmt::Debug, V> fmt::Debug for UseReducerHandle<T, V> {
184184
.finish()
185185
}
186186
}
187+
188+
impl<State, Action> PartialEq for UseReducerHandle<State, Action> {
189+
fn eq(&self, other: &Self) -> bool {
190+
// if the value is the same pointer
191+
// then we can assume that that setter is also the same thing
192+
Rc::ptr_eq(&self.value, &other.value)
193+
}
194+
}

packages/yew/src/functional/hooks/use_state.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,11 @@ impl<T> Clone for UseStateHandle<T> {
9797
}
9898
}
9999
}
100+
101+
impl <T> PartialEq for UseStateHandle<T> {
102+
fn eq(&self, other: &Self) -> bool {
103+
// if the value is the same pointer
104+
// then we can assume that that setter is also the same thing
105+
Rc::ptr_eq(&self.value, &other.value)
106+
}
107+
}

0 commit comments

Comments
 (0)