about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crates/core_simd/src/mod.rs1
-rw-r--r--crates/core_simd/src/round.rs42
-rw-r--r--crates/core_simd/src/vector.rs25
3 files changed, 25 insertions, 43 deletions
diff --git a/crates/core_simd/src/mod.rs b/crates/core_simd/src/mod.rs
index 590b2e4a153..b472aa3abe2 100644
--- a/crates/core_simd/src/mod.rs
+++ b/crates/core_simd/src/mod.rs
@@ -14,7 +14,6 @@ mod lane_count;
 mod masks;
 mod ops;
 mod ord;
-mod round;
 mod select;
 mod vector;
 mod vendor;
diff --git a/crates/core_simd/src/round.rs b/crates/core_simd/src/round.rs
deleted file mode 100644
index e111f3e0494..00000000000
--- a/crates/core_simd/src/round.rs
+++ /dev/null
@@ -1,42 +0,0 @@
-use crate::simd::intrinsics;
-use crate::simd::{LaneCount, Simd, SimdElement, SupportedLaneCount};
-use core::convert::FloatToInt;
-
-macro_rules! implement {
-    {
-        $type:ty
-    } => {
-        impl<const LANES: usize> Simd<$type, LANES>
-        where
-            LaneCount<LANES>: SupportedLaneCount,
-        {
-            /// Rounds toward zero and converts to the same-width integer type, assuming that
-            /// the value is finite and fits in that type.
-            ///
-            /// # Safety
-            /// The value must:
-            ///
-            /// * Not be NaN
-            /// * Not be infinite
-            /// * Be representable in the return type, after truncating off its fractional part
-            ///
-            /// If these requirements are infeasible or costly, consider using the safe function [cast],
-            /// which saturates on conversion.
-            ///
-            /// [cast]: Simd::cast
-            #[inline]
-            pub unsafe fn to_int_unchecked<I>(self) -> Simd<I, LANES>
-            where
-                $type: FloatToInt<I>,
-                I: SimdElement,
-            {
-                // Safety: `self` is a vector, and `FloatToInt` ensures the type can be casted to
-                // an integer.
-                unsafe { intrinsics::simd_cast(self) }
-            }
-        }
-    }
-}
-
-implement! { f32 }
-implement! { f64 }
diff --git a/crates/core_simd/src/vector.rs b/crates/core_simd/src/vector.rs
index fac7dca51f4..7433a695da9 100644
--- a/crates/core_simd/src/vector.rs
+++ b/crates/core_simd/src/vector.rs
@@ -217,6 +217,31 @@ where
         unsafe { intrinsics::simd_as(self) }
     }
 
+    /// Rounds toward zero and converts to the same-width integer type, assuming that
+    /// the value is finite and fits in that type.
+    ///
+    /// # Safety
+    /// The value must:
+    ///
+    /// * Not be NaN
+    /// * Not be infinite
+    /// * Be representable in the return type, after truncating off its fractional part
+    ///
+    /// If these requirements are infeasible or costly, consider using the safe function [cast],
+    /// which saturates on conversion.
+    ///
+    /// [cast]: Simd::cast
+    #[inline]
+    pub unsafe fn to_int_unchecked<I>(self) -> Simd<I, LANES>
+    where
+        T: core::convert::FloatToInt<I>,
+        I: SimdElement,
+    {
+        // Safety: `self` is a vector, and `FloatToInt` ensures the type can be casted to
+        // an integer.
+        unsafe { intrinsics::simd_cast(self) }
+    }
+
     /// Reads from potentially discontiguous indices in `slice` to construct a SIMD vector.
     /// If an index is out-of-bounds, the lane is instead selected from the `or` vector.
     ///