From 8f50a17c37a214632c2f5cf5b8f2833a7286883b Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 22 Apr 2023 19:27:22 -0700 Subject: [PATCH] Fixups for sync - Fix LANES over-replace - Bring in traits - Use less inference-heavy types --- crates/core_simd/src/vector.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/core_simd/src/vector.rs b/crates/core_simd/src/vector.rs index 0253f122c98..3323b92e37b 100644 --- a/crates/core_simd/src/vector.rs +++ b/crates/core_simd/src/vector.rs @@ -2,6 +2,7 @@ use crate::simd::{ intrinsics, LaneCount, Mask, MaskElement, SimdCast, SimdCastPtr, SimdConstPtr, SimdMutPtr, SimdPartialOrd, SupportedLaneCount, Swizzle, }; +use core::convert::{TryFrom, TryInto}; /// A SIMD vector with the shape of `[T; N]` but the operations of `T`. /// @@ -109,7 +110,7 @@ where T: SimdElement, { /// Number of elements in this vector. - pub const N: usize = N; + pub const LANES: usize = N; /// Returns the number of elements in this SIMD vector. /// @@ -122,7 +123,7 @@ where /// assert_eq!(v.lanes(), 4); /// ``` pub const fn lanes(&self) -> usize { - Self::N + Self::LANES } /// Constructs a new SIMD vector with all elements set to the given value. @@ -260,7 +261,7 @@ where #[must_use] pub const fn from_slice(slice: &[T]) -> Self { assert!( - slice.len() >= Self::N, + slice.len() >= Self::LANES, "slice length must be at least the number of elements" ); // SAFETY: We just checked that the slice contains @@ -288,7 +289,7 @@ where /// ``` pub fn copy_to_slice(self, slice: &mut [T]) { assert!( - slice.len() >= Self::N, + slice.len() >= Self::LANES, "slice length must be at least the number of elements" ); // SAFETY: We just checked that the slice contains @@ -883,7 +884,7 @@ where { type Error = core::array::TryFromSliceError; - fn try_from(slice: &[T]) -> Result { + fn try_from(slice: &[T]) -> Result { Ok(Self::from_array(slice.try_into()?)) } } @@ -895,7 +896,7 @@ where { type Error = core::array::TryFromSliceError; - fn try_from(slice: &mut [T]) -> Result { + fn try_from(slice: &mut [T]) -> Result { Ok(Self::from_array(slice.try_into()?)) } }