mirror of
https://github.com/serde-rs/json.git
synced 2026-03-29 22:50:53 +00:00
Manual implementation of Number's PartialEq.
To please clippy.
This commit is contained in:
@@ -22,7 +22,7 @@ pub struct Number {
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "arbitrary_precision"))]
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
#[derive(Copy, Clone)]
|
||||
enum N {
|
||||
PosInt(u64),
|
||||
/// Always less than zero.
|
||||
@@ -31,6 +31,18 @@ enum N {
|
||||
Float(f64),
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "arbitrary_precision"))]
|
||||
impl PartialEq for N {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
match (self, other) {
|
||||
(Self::PosInt(a), Self::PosInt(b)) => a == b,
|
||||
(Self::NegInt(a), Self::NegInt(b)) => a == b,
|
||||
(Self::Float(a), Self::Float(b)) => a == b,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Implementing Eq is fine since any float values are always finite.
|
||||
#[cfg(not(feature = "arbitrary_precision"))]
|
||||
impl Eq for N {}
|
||||
|
||||
Reference in New Issue
Block a user