diff options
| author | Christopher Durham <cad97@cad97.com> | 2025-03-26 14:32:35 -0400 |
|---|---|---|
| committer | Christopher Durham <cad97@cad97.com> | 2025-03-26 14:32:35 -0400 |
| commit | 2e5a76cd1e3a88b22fe4a38428cdabcbddfd0b4a (patch) | |
| tree | cf4b7da961a6c78c53bb9d249519412c95e22a85 /library/core/src/num | |
| parent | 19cab6b878ab18dce4816d85ac52b317214c485f (diff) | |
Use cfg_match in core
Diffstat (limited to 'library/core/src/num')
| -rw-r--r-- | library/core/src/num/f32.rs | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs index 79d864e1b19..53373584d55 100644 --- a/library/core/src/num/f32.rs +++ b/library/core/src/num/f32.rs @@ -14,7 +14,7 @@ use crate::convert::FloatToInt; use crate::num::FpCategory; use crate::panic::const_assert; -use crate::{intrinsics, mem}; +use crate::{cfg_match, intrinsics, mem}; /// The radix or base of the internal representation of `f32`. /// Use [`f32::RADIX`] instead. @@ -996,21 +996,22 @@ impl f32 { #[stable(feature = "num_midpoint", since = "1.85.0")] #[rustc_const_stable(feature = "num_midpoint", since = "1.85.0")] pub const fn midpoint(self, other: f32) -> f32 { - cfg_if! { + cfg_match! { // Allow faster implementation that have known good 64-bit float // implementations. Falling back to the branchy code on targets that don't // have 64-bit hardware floats or buggy implementations. // https://github.com/rust-lang/rust/pull/121062#issuecomment-2123408114 - if #[cfg(any( - target_arch = "x86_64", - target_arch = "aarch64", - all(any(target_arch = "riscv32", target_arch = "riscv64"), target_feature = "d"), - all(target_arch = "arm", target_feature = "vfp2"), - target_arch = "wasm32", - target_arch = "wasm64", - ))] { + any( + target_arch = "x86_64", + target_arch = "aarch64", + all(any(target_arch = "riscv32", target_arch = "riscv64"), target_feature = "d"), + all(target_arch = "arm", target_feature = "vfp2"), + target_arch = "wasm32", + target_arch = "wasm64", + ) => { ((self as f64 + other as f64) / 2.0) as f32 - } else { + } + _ => { const LO: f32 = f32::MIN_POSITIVE * 2.; const HI: f32 = f32::MAX / 2.; |
