/src/json/src/value/partial_eq.rs
Line | Count | Source |
1 | | use super::Value; |
2 | | use alloc::string::String; |
3 | | |
4 | 0 | fn eq_i64(value: &Value, other: i64) -> bool { |
5 | 0 | value.as_i64() == Some(other) |
6 | 0 | } |
7 | | |
8 | 0 | fn eq_u64(value: &Value, other: u64) -> bool { |
9 | 0 | value.as_u64() == Some(other) |
10 | 0 | } |
11 | | |
12 | 0 | fn eq_f32(value: &Value, other: f32) -> bool { |
13 | 0 | match value { |
14 | 0 | Value::Number(n) => n.as_f32() == Some(other), |
15 | 0 | _ => false, |
16 | | } |
17 | 0 | } |
18 | | |
19 | 0 | fn eq_f64(value: &Value, other: f64) -> bool { |
20 | 0 | value.as_f64() == Some(other) |
21 | 0 | } |
22 | | |
23 | 0 | fn eq_bool(value: &Value, other: bool) -> bool { |
24 | 0 | value.as_bool() == Some(other) |
25 | 0 | } |
26 | | |
27 | 0 | fn eq_str(value: &Value, other: &str) -> bool { |
28 | 0 | value.as_str() == Some(other) |
29 | 0 | } |
30 | | |
31 | | impl PartialEq<str> for Value { |
32 | 0 | fn eq(&self, other: &str) -> bool { |
33 | 0 | eq_str(self, other) |
34 | 0 | } |
35 | | } |
36 | | |
37 | | impl PartialEq<&str> for Value { |
38 | 0 | fn eq(&self, other: &&str) -> bool { |
39 | 0 | eq_str(self, *other) |
40 | 0 | } |
41 | | } |
42 | | |
43 | | impl PartialEq<Value> for str { |
44 | 0 | fn eq(&self, other: &Value) -> bool { |
45 | 0 | eq_str(other, self) |
46 | 0 | } |
47 | | } |
48 | | |
49 | | impl PartialEq<Value> for &str { |
50 | 0 | fn eq(&self, other: &Value) -> bool { |
51 | 0 | eq_str(other, *self) |
52 | 0 | } |
53 | | } |
54 | | |
55 | | impl PartialEq<String> for Value { |
56 | 0 | fn eq(&self, other: &String) -> bool { |
57 | 0 | eq_str(self, other.as_str()) |
58 | 0 | } |
59 | | } |
60 | | |
61 | | impl PartialEq<Value> for String { |
62 | 0 | fn eq(&self, other: &Value) -> bool { |
63 | 0 | eq_str(other, self.as_str()) |
64 | 0 | } |
65 | | } |
66 | | |
67 | | macro_rules! partialeq_numeric { |
68 | | ($($eq:ident [$($ty:ty)*])*) => { |
69 | | $($( |
70 | | impl PartialEq<$ty> for Value { |
71 | 0 | fn eq(&self, other: &$ty) -> bool { |
72 | 0 | $eq(self, *other as _) |
73 | 0 | } Unexecuted instantiation: <serde_json::value::Value as core::cmp::PartialEq<i8>>::eq Unexecuted instantiation: <serde_json::value::Value as core::cmp::PartialEq<i16>>::eq Unexecuted instantiation: <serde_json::value::Value as core::cmp::PartialEq<u64>>::eq Unexecuted instantiation: <serde_json::value::Value as core::cmp::PartialEq<usize>>::eq Unexecuted instantiation: <serde_json::value::Value as core::cmp::PartialEq<f32>>::eq Unexecuted instantiation: <serde_json::value::Value as core::cmp::PartialEq<f64>>::eq Unexecuted instantiation: <serde_json::value::Value as core::cmp::PartialEq<bool>>::eq Unexecuted instantiation: <serde_json::value::Value as core::cmp::PartialEq<i32>>::eq Unexecuted instantiation: <serde_json::value::Value as core::cmp::PartialEq<i64>>::eq Unexecuted instantiation: <serde_json::value::Value as core::cmp::PartialEq<isize>>::eq Unexecuted instantiation: <serde_json::value::Value as core::cmp::PartialEq<u8>>::eq Unexecuted instantiation: <serde_json::value::Value as core::cmp::PartialEq<u16>>::eq Unexecuted instantiation: <serde_json::value::Value as core::cmp::PartialEq<u32>>::eq |
74 | | } |
75 | | |
76 | | impl PartialEq<Value> for $ty { |
77 | 0 | fn eq(&self, other: &Value) -> bool { |
78 | 0 | $eq(other, *self as _) |
79 | 0 | } Unexecuted instantiation: <i8 as core::cmp::PartialEq<serde_json::value::Value>>::eq Unexecuted instantiation: <i16 as core::cmp::PartialEq<serde_json::value::Value>>::eq Unexecuted instantiation: <u64 as core::cmp::PartialEq<serde_json::value::Value>>::eq Unexecuted instantiation: <usize as core::cmp::PartialEq<serde_json::value::Value>>::eq Unexecuted instantiation: <f32 as core::cmp::PartialEq<serde_json::value::Value>>::eq Unexecuted instantiation: <f64 as core::cmp::PartialEq<serde_json::value::Value>>::eq Unexecuted instantiation: <bool as core::cmp::PartialEq<serde_json::value::Value>>::eq Unexecuted instantiation: <i32 as core::cmp::PartialEq<serde_json::value::Value>>::eq Unexecuted instantiation: <i64 as core::cmp::PartialEq<serde_json::value::Value>>::eq Unexecuted instantiation: <isize as core::cmp::PartialEq<serde_json::value::Value>>::eq Unexecuted instantiation: <u8 as core::cmp::PartialEq<serde_json::value::Value>>::eq Unexecuted instantiation: <u16 as core::cmp::PartialEq<serde_json::value::Value>>::eq Unexecuted instantiation: <u32 as core::cmp::PartialEq<serde_json::value::Value>>::eq |
80 | | } |
81 | | |
82 | | impl<'a> PartialEq<$ty> for &'a Value { |
83 | 0 | fn eq(&self, other: &$ty) -> bool { |
84 | 0 | $eq(*self, *other as _) |
85 | 0 | } Unexecuted instantiation: <&serde_json::value::Value as core::cmp::PartialEq<i8>>::eq Unexecuted instantiation: <&serde_json::value::Value as core::cmp::PartialEq<u64>>::eq Unexecuted instantiation: <&serde_json::value::Value as core::cmp::PartialEq<usize>>::eq Unexecuted instantiation: <&serde_json::value::Value as core::cmp::PartialEq<f32>>::eq Unexecuted instantiation: <&serde_json::value::Value as core::cmp::PartialEq<f64>>::eq Unexecuted instantiation: <&serde_json::value::Value as core::cmp::PartialEq<bool>>::eq Unexecuted instantiation: <&serde_json::value::Value as core::cmp::PartialEq<i16>>::eq Unexecuted instantiation: <&serde_json::value::Value as core::cmp::PartialEq<i32>>::eq Unexecuted instantiation: <&serde_json::value::Value as core::cmp::PartialEq<i64>>::eq Unexecuted instantiation: <&serde_json::value::Value as core::cmp::PartialEq<isize>>::eq Unexecuted instantiation: <&serde_json::value::Value as core::cmp::PartialEq<u8>>::eq Unexecuted instantiation: <&serde_json::value::Value as core::cmp::PartialEq<u16>>::eq Unexecuted instantiation: <&serde_json::value::Value as core::cmp::PartialEq<u32>>::eq |
86 | | } |
87 | | |
88 | | impl<'a> PartialEq<$ty> for &'a mut Value { |
89 | 0 | fn eq(&self, other: &$ty) -> bool { |
90 | 0 | $eq(*self, *other as _) |
91 | 0 | } Unexecuted instantiation: <&mut serde_json::value::Value as core::cmp::PartialEq<i8>>::eq Unexecuted instantiation: <&mut serde_json::value::Value as core::cmp::PartialEq<u64>>::eq Unexecuted instantiation: <&mut serde_json::value::Value as core::cmp::PartialEq<usize>>::eq Unexecuted instantiation: <&mut serde_json::value::Value as core::cmp::PartialEq<f32>>::eq Unexecuted instantiation: <&mut serde_json::value::Value as core::cmp::PartialEq<f64>>::eq Unexecuted instantiation: <&mut serde_json::value::Value as core::cmp::PartialEq<bool>>::eq Unexecuted instantiation: <&mut serde_json::value::Value as core::cmp::PartialEq<i16>>::eq Unexecuted instantiation: <&mut serde_json::value::Value as core::cmp::PartialEq<i32>>::eq Unexecuted instantiation: <&mut serde_json::value::Value as core::cmp::PartialEq<i64>>::eq Unexecuted instantiation: <&mut serde_json::value::Value as core::cmp::PartialEq<isize>>::eq Unexecuted instantiation: <&mut serde_json::value::Value as core::cmp::PartialEq<u8>>::eq Unexecuted instantiation: <&mut serde_json::value::Value as core::cmp::PartialEq<u16>>::eq Unexecuted instantiation: <&mut serde_json::value::Value as core::cmp::PartialEq<u32>>::eq |
92 | | } |
93 | | )*)* |
94 | | } |
95 | | } |
96 | | |
97 | | partialeq_numeric! { |
98 | | eq_i64[i8 i16 i32 i64 isize] |
99 | | eq_u64[u8 u16 u32 u64 usize] |
100 | | eq_f32[f32] |
101 | | eq_f64[f64] |
102 | | eq_bool[bool] |
103 | | } |