From 85f79fa753dd358b9c41cc42d63ba4b1a6d7d3e8 Mon Sep 17 00:00:00 2001 From: upstream Date: Fri, 4 Sep 2026 09:45:03 +0200 Subject: [PATCH] Upstream magiclen/byte-unit state of the touched files before 4d115cc977 --- src/common.rs | 16 ++-------------- tests/byte.rs | 10 ---------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/src/common.rs b/src/common.rs index b05c028..ee94712 100644 --- a/src/common.rs +++ b/src/common.rs @@ -36,13 +36,7 @@ pub(crate) fn ceil_f64(v: f64) -> f64 { pub(crate) fn ceil_f64(v: f64) -> f64 { debug_assert!(v >= 0.0); - // `Decimal::from_f64` returns `None` for non-finite values (e.g. infinity), - // so fall back to the input to mirror `f64::ceil` in the `std` path and - // avoid panicking. - match Decimal::from_f64(v) { - Some(d) => d.ceil().to_f64().unwrap_or(v), - None => v, - } + Decimal::from_f64(v).unwrap().ceil().to_f64().unwrap() } #[cfg(any(feature = "byte", feature = "bit"))] @@ -60,13 +54,7 @@ pub(crate) fn ceil_f32(v: f32) -> f32 { pub(crate) fn ceil_f32(v: f32) -> f32 { debug_assert!(v >= 0.0); - // `Decimal::from_f32` returns `None` for non-finite values (e.g. infinity), - // so fall back to the input to mirror `f32::ceil` in the `std` path and - // avoid panicking. - match Decimal::from_f32(v) { - Some(d) => d.ceil().to_f32().unwrap_or(v), - None => v, - } + Decimal::from_f32(v).unwrap().ceil().to_f32().unwrap() } #[cfg(any(feature = "byte", feature = "bit"))] diff --git a/tests/byte.rs b/tests/byte.rs index c1429b4..8687ce1 100644 --- a/tests/byte.rs +++ b/tests/byte.rs @@ -170,13 +170,3 @@ fn tests() { assert_eq!(byte, serde_json::from_str::(case.0).unwrap(), "{i}"); } } - -#[test] -fn from_non_finite_returns_none() { - // Non-finite inputs are "too large" and must return None instead of - // panicking, consistently across the `std` and `no_std` builds. - assert_eq!(Byte::from_f64(f64::INFINITY), None); - assert_eq!(Byte::from_f64(f64::NAN), None); - assert_eq!(Byte::from_f32(f32::INFINITY), None); - assert_eq!(Byte::from_f32(f32::NAN), None); -}