diff --git a/packages/hooks/src/usestate.rs b/packages/hooks/src/usestate.rs index 9e3fb5eed..a2da3c885 100644 --- a/packages/hooks/src/usestate.rs +++ b/packages/hooks/src/usestate.rs @@ -336,6 +336,50 @@ impl PartialEq> for UseState { } } +impl PartialOrd for UseState { + fn ge(&self, other: &T) -> bool { + *self.current_val >= *other + } + + fn gt(&self, other: &T) -> bool { + *self.current_val > *other + } + + fn le(&self, other: &T) -> bool { + *self.current_val <= *other + } + + fn lt(&self, other: &T) -> bool { + *self.current_val < *other + } + + fn partial_cmp(&self, other: &T) -> Option { + (*self.current_val).partial_cmp(other) + } +} + +impl PartialOrd> for UseState { + fn ge(&self, other: &UseState) -> bool { + self.current_val >= other.current_val + } + + fn gt(&self, other: &UseState) -> bool { + self.current_val > other.current_val + } + + fn le(&self, other: &UseState) -> bool { + self.current_val <= other.current_val + } + + fn lt(&self, other: &UseState) -> bool { + self.current_val < other.current_val + } + + fn partial_cmp(&self, other: &UseState) -> Option { + self.current_val.partial_cmp(&other.current_val) + } +} + impl Debug for UseState { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{:?}", self.current_val)