Skip to content

Commit 6ff74ed

Browse files
committed
Fix PartialEq for Value in opentelemetry-stdout
PartialEq's previous implementation called back to itself with the same arguments. Here we extract the underlying value and compare them. If the enum types are different, it returns false.
1 parent a1f02fa commit 6ff74ed

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

opentelemetry-stdout/src/common.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,21 @@ pub(crate) enum Value {
8686

8787
impl PartialEq for Value {
8888
fn eq(&self, other: &Self) -> bool {
89-
match (&self, &other) {
89+
match (self, other) {
90+
(Value::Bool(b), Value::Bool(ob)) => b.eq(ob),
91+
(Value::Int(i), Value::Int(oi)) => i.eq(oi),
9092
(Value::Double(f), Value::Double(of)) => OrderedFloat(*f).eq(&OrderedFloat(*of)),
91-
(non_double, other_non_double) => non_double.eq(other_non_double),
93+
(Value::String(s), Value::String(os)) => s.eq(os),
94+
(Value::Array(a), Value::Array(oa)) => a.eq(oa),
95+
(Value::KeyValues(kv), Value::KeyValues(okv)) => kv.eq(okv),
96+
(Value::BytesValue(b), Value::BytesValue(ob)) => b.eq(ob),
97+
(Value::Bool(_), _) => false,
98+
(Value::Int(_), _) => false,
99+
(Value::Double(_), _) => false,
100+
(Value::String(_), _) => false,
101+
(Value::Array(_), _) => false,
102+
(Value::KeyValues(_), _) => false,
103+
(Value::BytesValue(_), _) => false,
92104
}
93105
}
94106
}

0 commit comments

Comments
 (0)