Manual implementation of Number's PartialEq.

To please clippy.
This commit is contained in:
Timothée Haudebourg
2021-10-20 14:13:14 +02:00
parent 10655c7639
commit c3ac6c0077

View File

@@ -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 {}