diff options
| author | Laurenz <laurmaedje@gmail.com> | 2025-02-24 13:28:01 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-24 12:28:01 +0000 |
| commit | 69c3f957051358eff961addbcae4ff02448513dc (patch) | |
| tree | 4108c418417313d084318ffecf59cab56de32cb9 /crates/typst-utils | |
| parent | ebe25432641a729780578a2440eaf9fb07c80e38 (diff) | |
Bump MSRV to 1.83 and Rust in CI to 1.85 (#5946)
Diffstat (limited to 'crates/typst-utils')
| -rw-r--r-- | crates/typst-utils/src/scalar.rs | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/crates/typst-utils/src/scalar.rs b/crates/typst-utils/src/scalar.rs index 4036c231..6d84fbfd 100644 --- a/crates/typst-utils/src/scalar.rs +++ b/crates/typst-utils/src/scalar.rs @@ -28,7 +28,7 @@ impl Scalar { /// /// If the value is NaN, then it is set to `0.0` in the result. pub const fn new(x: f64) -> Self { - Self(if is_nan(x) { 0.0 } else { x }) + Self(if x.is_nan() { 0.0 } else { x }) } /// Gets the value of this [`Scalar`]. @@ -37,17 +37,6 @@ impl Scalar { } } -// We have to detect NaNs this way since `f64::is_nan` isn’t const -// on stable yet: -// ([tracking issue](https://github.com/rust-lang/rust/issues/57241)) -#[allow(clippy::unusual_byte_groupings)] -const fn is_nan(x: f64) -> bool { - // Safety: all bit patterns are valid for u64, and f64 has no padding bits. - // We cannot use `f64::to_bits` because it is not const. - let x_bits = unsafe { std::mem::transmute::<f64, u64>(x) }; - (x_bits << 1 >> (64 - 12 + 1)) == 0b0_111_1111_1111 && (x_bits << 12) != 0 -} - impl Numeric for Scalar { fn zero() -> Self { Self(0.0) |
