mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
uucore/format: remove Display impl
of ExtendedBigDecimal
This commit is contained in:
@@ -21,7 +21,6 @@
|
||||
//! assert_eq!(summand1 + summand2, ExtendedBigDecimal::Infinity);
|
||||
//! ```
|
||||
use std::cmp::Ordering;
|
||||
use std::fmt::Display;
|
||||
use std::ops::Add;
|
||||
use std::ops::Neg;
|
||||
|
||||
@@ -110,25 +109,6 @@ impl ExtendedBigDecimal {
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for ExtendedBigDecimal {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::BigDecimal(x) => {
|
||||
let (n, p) = x.as_bigint_and_exponent();
|
||||
match p {
|
||||
0 => Self::BigDecimal(BigDecimal::new(n * 10, 1)).fmt(f),
|
||||
_ => x.fmt(f),
|
||||
}
|
||||
}
|
||||
Self::Infinity => f32::INFINITY.fmt(f),
|
||||
Self::MinusInfinity => f32::NEG_INFINITY.fmt(f),
|
||||
Self::MinusZero => (-0.0f32).fmt(f),
|
||||
Self::Nan => "nan".fmt(f),
|
||||
Self::MinusNan => "-nan".fmt(f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Zero for ExtendedBigDecimal {
|
||||
fn zero() -> Self {
|
||||
Self::BigDecimal(BigDecimal::zero())
|
||||
@@ -281,16 +261,4 @@ mod tests {
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_display() {
|
||||
assert_eq!(
|
||||
format!("{}", ExtendedBigDecimal::BigDecimal(BigDecimal::zero())),
|
||||
"0.0"
|
||||
);
|
||||
assert_eq!(format!("{}", ExtendedBigDecimal::Infinity), "inf");
|
||||
assert_eq!(format!("{}", ExtendedBigDecimal::MinusInfinity), "-inf");
|
||||
assert_eq!(format!("{}", ExtendedBigDecimal::Nan), "nan");
|
||||
assert_eq!(format!("{}", ExtendedBigDecimal::MinusZero), "-0");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user