Skip to content

Commit 4ac9f6c

Browse files
authored
Merge pull request #640 from smarnach/smarnach/eq-impls
Implement Eq for Map, Number and Value.
2 parents 50656bd + 99eb4ea commit 4ac9f6c

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/map.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ impl PartialEq for Map<String, Value> {
233233
}
234234
}
235235

236+
impl Eq for Map<String, Value> {}
237+
236238
/// Access an element of this map. Panics if the given key is not present in the
237239
/// map.
238240
///

src/number.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use serde::de::{IntoDeserializer, MapAccess};
1616
pub(crate) const TOKEN: &str = "$serde_json::private::Number";
1717

1818
/// Represents a JSON number, whether integer or floating point.
19-
#[derive(Clone, PartialEq)]
19+
#[derive(Clone, Eq, PartialEq)]
2020
pub struct Number {
2121
n: N,
2222
}
@@ -31,6 +31,10 @@ enum N {
3131
Float(f64),
3232
}
3333

34+
// Implementing Eq is fine since any float values are always finite.
35+
#[cfg(not(feature = "arbitrary_precision"))]
36+
impl Eq for N {}
37+
3438
#[cfg(feature = "arbitrary_precision")]
3539
type N = String;
3640

src/value/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub use crate::raw::RawValue;
107107
/// Represents any valid JSON value.
108108
///
109109
/// See the `serde_json::value` module documentation for usage examples.
110-
#[derive(Clone, PartialEq)]
110+
#[derive(Clone, Eq, PartialEq)]
111111
pub enum Value {
112112
/// Represents a JSON null value.
113113
///

0 commit comments

Comments
 (0)