diff --git a/src/map.rs b/src/map.rs index c523fcfb4..9891d5b3b 100644 --- a/src/map.rs +++ b/src/map.rs @@ -233,6 +233,8 @@ impl PartialEq for Map { } } +impl Eq for Map {} + /// Access an element of this map. Panics if the given key is not present in the /// map. /// diff --git a/src/number.rs b/src/number.rs index f13a4f9e6..e56faee6d 100644 --- a/src/number.rs +++ b/src/number.rs @@ -16,7 +16,7 @@ use serde::de::{IntoDeserializer, MapAccess}; pub(crate) const TOKEN: &str = "$serde_json::private::Number"; /// Represents a JSON number, whether integer or floating point. -#[derive(Clone, PartialEq)] +#[derive(Clone, Eq, PartialEq)] pub struct Number { n: N, } @@ -31,6 +31,10 @@ enum N { Float(f64), } +// Implementing Eq is fine since any float values are always finite. +#[cfg(not(feature = "arbitrary_precision"))] +impl Eq for N {} + #[cfg(feature = "arbitrary_precision")] type N = String; diff --git a/src/value/mod.rs b/src/value/mod.rs index 3ddabe2b3..d806ee971 100644 --- a/src/value/mod.rs +++ b/src/value/mod.rs @@ -107,7 +107,7 @@ pub use crate::raw::RawValue; /// Represents any valid JSON value. /// /// See the `serde_json::value` module documentation for usage examples. -#[derive(Clone, PartialEq)] +#[derive(Clone, Eq, PartialEq)] pub enum Value { /// Represents a JSON null value. ///