scratch_test_value/comparisons/
cmp_traits.rs1use crate::{SNumber, SValue};
2
3impl PartialEq for SNumber {
4 fn eq(&self, other: &Self) -> bool {
5 self.q_eq(other, &mut ())
6 }
7}
8
9impl PartialEq for SValue {
10 fn eq(&self, other: &Self) -> bool {
11 self.q_eq(other, &mut ())
12 }
13}
14
15impl PartialEq<SValue> for &SValue {
16 fn eq(&self, other: &SValue) -> bool {
17 self.q_eq(other, &mut ())
18 }
19}
20
21impl PartialEq<&SValue> for SValue {
22 fn eq(&self, other: &&SValue) -> bool {
23 self.q_eq(other, &mut ())
24 }
25}
26
27impl PartialOrd for SValue {
28 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
29 if self.q_lt(other, &mut ()) {
30 Some(std::cmp::Ordering::Less)
31 } else if self.q_gt(other, &mut ()) {
32 Some(std::cmp::Ordering::Greater)
33 } else {
34 (self == other).then_some(std::cmp::Ordering::Equal)
35 }
36 }
37}
38
39impl PartialOrd for SNumber {
40 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
41 if self.q_lt(other, &mut ()) {
42 Some(std::cmp::Ordering::Less)
43 } else if self.q_gt(other, &mut ()) {
44 Some(std::cmp::Ordering::Greater)
45 } else {
46 (self == other).then_some(std::cmp::Ordering::Equal)
47 }
48 }
49}