diff --git a/crates/core_simd/src/comparisons.rs b/crates/core_simd/src/comparisons.rs index c094f680a59d..601576e094fa 100644 --- a/crates/core_simd/src/comparisons.rs +++ b/crates/core_simd/src/comparisons.rs @@ -1,49 +1,49 @@ use crate::{LaneCount, Mask, Simd, SimdElement, SupportedLaneCount}; -impl Simd +impl Simd where - Element: SimdElement + PartialEq, + T: SimdElement + PartialEq, LaneCount: SupportedLaneCount, { /// Test if each lane is equal to the corresponding lane in `other`. #[inline] - pub fn lanes_eq(self, other: Self) -> Mask { + pub fn lanes_eq(self, other: Self) -> Mask { unsafe { Mask::from_int_unchecked(crate::intrinsics::simd_eq(self, other)) } } /// Test if each lane is not equal to the corresponding lane in `other`. #[inline] - pub fn lanes_ne(self, other: Self) -> Mask { + pub fn lanes_ne(self, other: Self) -> Mask { unsafe { Mask::from_int_unchecked(crate::intrinsics::simd_ne(self, other)) } } } -impl Simd +impl Simd where - Element: SimdElement + PartialOrd, + T: SimdElement + PartialOrd, LaneCount: SupportedLaneCount, { /// Test if each lane is less than the corresponding lane in `other`. #[inline] - pub fn lanes_lt(self, other: Self) -> Mask { + pub fn lanes_lt(self, other: Self) -> Mask { unsafe { Mask::from_int_unchecked(crate::intrinsics::simd_lt(self, other)) } } /// Test if each lane is greater than the corresponding lane in `other`. #[inline] - pub fn lanes_gt(self, other: Self) -> Mask { + pub fn lanes_gt(self, other: Self) -> Mask { unsafe { Mask::from_int_unchecked(crate::intrinsics::simd_gt(self, other)) } } /// Test if each lane is less than or equal to the corresponding lane in `other`. #[inline] - pub fn lanes_le(self, other: Self) -> Mask { + pub fn lanes_le(self, other: Self) -> Mask { unsafe { Mask::from_int_unchecked(crate::intrinsics::simd_le(self, other)) } } /// Test if each lane is greater than or equal to the corresponding lane in `other`. #[inline] - pub fn lanes_ge(self, other: Self) -> Mask { + pub fn lanes_ge(self, other: Self) -> Mask { unsafe { Mask::from_int_unchecked(crate::intrinsics::simd_ge(self, other)) } } } diff --git a/crates/core_simd/src/fmt.rs b/crates/core_simd/src/fmt.rs index 9ad3a6c100ea..c3947c92f2a9 100644 --- a/crates/core_simd/src/fmt.rs +++ b/crates/core_simd/src/fmt.rs @@ -1,10 +1,10 @@ macro_rules! impl_fmt_trait { { $($trait:ident,)* } => { $( - impl core::fmt::$trait for crate::Simd + impl core::fmt::$trait for crate::Simd where crate::LaneCount: crate::SupportedLaneCount, - Element: crate::SimdElement + core::fmt::$trait, + T: crate::SimdElement + core::fmt::$trait, { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { #[repr(transparent)] diff --git a/crates/core_simd/src/masks.rs b/crates/core_simd/src/masks.rs index b433712a3291..14b1fe08ffbd 100644 --- a/crates/core_simd/src/masks.rs +++ b/crates/core_simd/src/masks.rs @@ -59,21 +59,21 @@ impl_element! { isize } /// /// The layout of this type is unspecified. #[repr(transparent)] -pub struct Mask(mask_impl::Mask) +pub struct Mask(mask_impl::Mask) where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount; -impl Copy for Mask +impl Copy for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { } -impl Clone for Mask +impl Clone for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { fn clone(&self) -> Self { @@ -81,9 +81,9 @@ where } } -impl Mask +impl Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { /// Construct a mask by setting all lanes to the given value. @@ -115,7 +115,7 @@ where /// # Safety /// All lanes must be either 0 or -1. #[inline] - pub unsafe fn from_int_unchecked(value: Simd) -> Self { + pub unsafe fn from_int_unchecked(value: Simd) -> Self { Self(mask_impl::Mask::from_int_unchecked(value)) } @@ -125,15 +125,15 @@ where /// # Panics /// Panics if any lane is not 0 or -1. #[inline] - pub fn from_int(value: Simd) -> Self { - assert!(Element::valid(value), "all values must be either 0 or -1",); + pub fn from_int(value: Simd) -> Self { + assert!(T::valid(value), "all values must be either 0 or -1",); unsafe { Self::from_int_unchecked(value) } } /// Converts the mask to a vector of integers, where 0 represents `false` and -1 /// represents `true`. #[inline] - pub fn to_int(self) -> Simd { + pub fn to_int(self) -> Simd { self.0.to_int() } @@ -201,9 +201,9 @@ where } // vector/array conversion -impl From<[bool; LANES]> for Mask +impl From<[bool; LANES]> for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { fn from(array: [bool; LANES]) -> Self { @@ -211,19 +211,19 @@ where } } -impl From> for [bool; LANES] +impl From> for [bool; LANES] where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { - fn from(vector: Mask) -> Self { + fn from(vector: Mask) -> Self { vector.to_array() } } -impl Default for Mask +impl Default for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { #[inline] @@ -232,9 +232,9 @@ where } } -impl PartialEq for Mask +impl PartialEq for Mask where - Element: MaskElement + PartialEq, + T: MaskElement + PartialEq, LaneCount: SupportedLaneCount, { #[inline] @@ -243,9 +243,9 @@ where } } -impl PartialOrd for Mask +impl PartialOrd for Mask where - Element: MaskElement + PartialOrd, + T: MaskElement + PartialOrd, LaneCount: SupportedLaneCount, { #[inline] @@ -254,9 +254,9 @@ where } } -impl core::fmt::Debug for Mask +impl core::fmt::Debug for Mask where - Element: MaskElement + core::fmt::Debug, + T: MaskElement + core::fmt::Debug, LaneCount: SupportedLaneCount, { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { @@ -266,9 +266,9 @@ where } } -impl core::ops::BitAnd for Mask +impl core::ops::BitAnd for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { type Output = Self; @@ -278,9 +278,9 @@ where } } -impl core::ops::BitAnd for Mask +impl core::ops::BitAnd for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { type Output = Self; @@ -290,21 +290,21 @@ where } } -impl core::ops::BitAnd> for bool +impl core::ops::BitAnd> for bool where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { - type Output = Mask; + type Output = Mask; #[inline] - fn bitand(self, rhs: Mask) -> Mask { + fn bitand(self, rhs: Mask) -> Mask { Mask::splat(self) & rhs } } -impl core::ops::BitOr for Mask +impl core::ops::BitOr for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { type Output = Self; @@ -314,9 +314,9 @@ where } } -impl core::ops::BitOr for Mask +impl core::ops::BitOr for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { type Output = Self; @@ -326,21 +326,21 @@ where } } -impl core::ops::BitOr> for bool +impl core::ops::BitOr> for bool where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { - type Output = Mask; + type Output = Mask; #[inline] - fn bitor(self, rhs: Mask) -> Mask { + fn bitor(self, rhs: Mask) -> Mask { Mask::splat(self) | rhs } } -impl core::ops::BitXor for Mask +impl core::ops::BitXor for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { type Output = Self; @@ -350,9 +350,9 @@ where } } -impl core::ops::BitXor for Mask +impl core::ops::BitXor for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { type Output = Self; @@ -362,33 +362,33 @@ where } } -impl core::ops::BitXor> for bool +impl core::ops::BitXor> for bool where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { - type Output = Mask; + type Output = Mask; #[inline] - fn bitxor(self, rhs: Mask) -> Self::Output { + fn bitxor(self, rhs: Mask) -> Self::Output { Mask::splat(self) ^ rhs } } -impl core::ops::Not for Mask +impl core::ops::Not for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { - type Output = Mask; + type Output = Mask; #[inline] fn not(self) -> Self::Output { Self(!self.0) } } -impl core::ops::BitAndAssign for Mask +impl core::ops::BitAndAssign for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { #[inline] @@ -397,9 +397,9 @@ where } } -impl core::ops::BitAndAssign for Mask +impl core::ops::BitAndAssign for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { #[inline] @@ -408,9 +408,9 @@ where } } -impl core::ops::BitOrAssign for Mask +impl core::ops::BitOrAssign for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { #[inline] @@ -419,9 +419,9 @@ where } } -impl core::ops::BitOrAssign for Mask +impl core::ops::BitOrAssign for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { #[inline] @@ -430,9 +430,9 @@ where } } -impl core::ops::BitXorAssign for Mask +impl core::ops::BitXorAssign for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { #[inline] @@ -441,9 +441,9 @@ where } } -impl core::ops::BitXorAssign for Mask +impl core::ops::BitXorAssign for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { #[inline] diff --git a/crates/core_simd/src/masks/bitmask.rs b/crates/core_simd/src/masks/bitmask.rs index 2b8309494510..0b5b3a5c595e 100644 --- a/crates/core_simd/src/masks/bitmask.rs +++ b/crates/core_simd/src/masks/bitmask.rs @@ -3,24 +3,24 @@ use core::marker::PhantomData; /// A mask where each lane is represented by a single bit. #[repr(transparent)] -pub struct Mask( +pub struct Mask( as SupportedLaneCount>::BitMask, - PhantomData, + PhantomData, ) where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount; -impl Copy for Mask +impl Copy for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { } -impl Clone for Mask +impl Clone for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { fn clone(&self) -> Self { @@ -28,9 +28,9 @@ where } } -impl PartialEq for Mask +impl PartialEq for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { fn eq(&self, other: &Self) -> bool { @@ -38,9 +38,9 @@ where } } -impl PartialOrd for Mask +impl PartialOrd for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { fn partial_cmp(&self, other: &Self) -> Option { @@ -48,16 +48,16 @@ where } } -impl Eq for Mask +impl Eq for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { } -impl Ord for Mask +impl Ord for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { fn cmp(&self, other: &Self) -> core::cmp::Ordering { @@ -65,9 +65,9 @@ where } } -impl Mask +impl Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { #[inline] @@ -95,20 +95,20 @@ where } #[inline] - pub fn to_int(self) -> Simd { + pub fn to_int(self) -> Simd { unsafe { let mask: as SupportedLaneCount>::IntBitMask = core::mem::transmute_copy(&self); crate::intrinsics::simd_select_bitmask( mask, - Simd::splat(Element::TRUE), - Simd::splat(Element::FALSE), + Simd::splat(T::TRUE), + Simd::splat(T::FALSE), ) } } #[inline] - pub unsafe fn from_int_unchecked(value: Simd) -> Self { + pub unsafe fn from_int_unchecked(value: Simd) -> Self { // TODO remove the transmute when rustc is more flexible assert_eq!( core::mem::size_of::< as SupportedLaneCount>::BitMask>(), @@ -132,9 +132,9 @@ where } #[inline] - pub fn convert(self) -> Mask + pub fn convert(self) -> Mask where - T: MaskElement, + U: MaskElement, { unsafe { core::mem::transmute_copy(&self) } } @@ -150,9 +150,9 @@ where } } -impl core::ops::BitAnd for Mask +impl core::ops::BitAnd for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, as SupportedLaneCount>::BitMask: AsRef<[u8]> + AsMut<[u8]>, { @@ -166,9 +166,9 @@ where } } -impl core::ops::BitOr for Mask +impl core::ops::BitOr for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, as SupportedLaneCount>::BitMask: AsRef<[u8]> + AsMut<[u8]>, { @@ -182,9 +182,9 @@ where } } -impl core::ops::BitXor for Mask +impl core::ops::BitXor for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { type Output = Self; @@ -197,9 +197,9 @@ where } } -impl core::ops::Not for Mask +impl core::ops::Not for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { type Output = Self; diff --git a/crates/core_simd/src/masks/full_masks.rs b/crates/core_simd/src/masks/full_masks.rs index b45ace3791d3..9c1cc4623f9a 100644 --- a/crates/core_simd/src/masks/full_masks.rs +++ b/crates/core_simd/src/masks/full_masks.rs @@ -4,21 +4,21 @@ use super::MaskElement; use crate::{LaneCount, Simd, SupportedLaneCount}; #[repr(transparent)] -pub struct Mask(Simd) +pub struct Mask(Simd) where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount; -impl Copy for Mask +impl Copy for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { } -impl Clone for Mask +impl Clone for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { #[inline] @@ -27,9 +27,9 @@ where } } -impl PartialEq for Mask +impl PartialEq for Mask where - Element: MaskElement + PartialEq, + T: MaskElement + PartialEq, LaneCount: SupportedLaneCount, { fn eq(&self, other: &Self) -> bool { @@ -37,9 +37,9 @@ where } } -impl PartialOrd for Mask +impl PartialOrd for Mask where - Element: MaskElement + PartialOrd, + T: MaskElement + PartialOrd, LaneCount: SupportedLaneCount, { fn partial_cmp(&self, other: &Self) -> Option { @@ -47,16 +47,16 @@ where } } -impl Eq for Mask +impl Eq for Mask where - Element: MaskElement + Eq, + T: MaskElement + Eq, LaneCount: SupportedLaneCount, { } -impl Ord for Mask +impl Ord for Mask where - Element: MaskElement + Ord, + T: MaskElement + Ord, LaneCount: SupportedLaneCount, { fn cmp(&self, other: &Self) -> core::cmp::Ordering { @@ -64,43 +64,39 @@ where } } -impl Mask +impl Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { pub fn splat(value: bool) -> Self { - Self(Simd::splat(if value { - Element::TRUE - } else { - Element::FALSE - })) + Self(Simd::splat(if value { T::TRUE } else { T::FALSE })) } #[inline] pub unsafe fn test_unchecked(&self, lane: usize) -> bool { - Element::eq(self.0[lane], Element::TRUE) + T::eq(self.0[lane], T::TRUE) } #[inline] pub unsafe fn set_unchecked(&mut self, lane: usize, value: bool) { - self.0[lane] = if value { Element::TRUE } else { Element::FALSE } + self.0[lane] = if value { T::TRUE } else { T::FALSE } } #[inline] - pub fn to_int(self) -> Simd { + pub fn to_int(self) -> Simd { self.0 } #[inline] - pub unsafe fn from_int_unchecked(value: Simd) -> Self { + pub unsafe fn from_int_unchecked(value: Simd) -> Self { Self(value) } #[inline] - pub fn convert(self) -> Mask + pub fn convert(self) -> Mask where - T: MaskElement, + U: MaskElement, { unsafe { Mask(crate::intrinsics::simd_cast(self.0)) } } @@ -170,19 +166,19 @@ where } } -impl core::convert::From> for Simd +impl core::convert::From> for Simd where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { - fn from(value: Mask) -> Self { + fn from(value: Mask) -> Self { value.0 } } -impl core::ops::BitAnd for Mask +impl core::ops::BitAnd for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { type Output = Self; @@ -192,9 +188,9 @@ where } } -impl core::ops::BitOr for Mask +impl core::ops::BitOr for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { type Output = Self; @@ -204,9 +200,9 @@ where } } -impl core::ops::BitXor for Mask +impl core::ops::BitXor for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { type Output = Self; @@ -216,9 +212,9 @@ where } } -impl core::ops::Not for Mask +impl core::ops::Not for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { type Output = Self; diff --git a/crates/core_simd/src/ops.rs b/crates/core_simd/src/ops.rs index 651498817c38..900315660005 100644 --- a/crates/core_simd/src/ops.rs +++ b/crates/core_simd/src/ops.rs @@ -1,10 +1,10 @@ use crate::{LaneCount, Simd, SimdElement, SupportedLaneCount}; -impl core::ops::Index for Simd +impl core::ops::Index for Simd where - Element: SimdElement, + T: SimdElement, LaneCount: SupportedLaneCount, - I: core::slice::SliceIndex<[Element]>, + I: core::slice::SliceIndex<[T]>, { type Output = I::Output; fn index(&self, index: I) -> &Self::Output { @@ -12,11 +12,11 @@ where } } -impl core::ops::IndexMut for Simd +impl core::ops::IndexMut for Simd where - Element: SimdElement, + T: SimdElement, LaneCount: SupportedLaneCount, - I: core::slice::SliceIndex<[Element]>, + I: core::slice::SliceIndex<[T]>, { fn index_mut(&mut self, index: I) -> &mut Self::Output { &mut self.as_mut_array()[index] diff --git a/crates/core_simd/src/permute.rs b/crates/core_simd/src/permute.rs index e1a085fd76db..cc58778b6b4b 100644 --- a/crates/core_simd/src/permute.rs +++ b/crates/core_simd/src/permute.rs @@ -1,8 +1,8 @@ macro_rules! impl_shuffle_lane { { $fn:ident, $n:literal } => { - impl crate::Simd + impl crate::Simd where - Element: crate::SimdElement, + T: crate::SimdElement, { /// A const SIMD shuffle that takes 2 SIMD vectors and produces another vector, using /// the indices in the const parameter. The first or "self" vector will have its lanes diff --git a/crates/core_simd/src/select.rs b/crates/core_simd/src/select.rs index 710d23a71d03..0951639c9426 100644 --- a/crates/core_simd/src/select.rs +++ b/crates/core_simd/src/select.rs @@ -11,34 +11,34 @@ pub trait Select: Sealed { fn select(mask: Mask, true_values: Self, false_values: Self) -> Self; } -impl Sealed for Simd +impl Sealed for Simd where - Element: SimdElement, + T: SimdElement, LaneCount: SupportedLaneCount, { } -impl Select> for Simd +impl Select> for Simd where - Element: SimdElement, + T: SimdElement, LaneCount: SupportedLaneCount, { #[inline] - fn select(mask: Mask, true_values: Self, false_values: Self) -> Self { + fn select(mask: Mask, true_values: Self, false_values: Self) -> Self { unsafe { crate::intrinsics::simd_select(mask.to_int(), true_values, false_values) } } } -impl Sealed for Mask +impl Sealed for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { } -impl Select for Mask +impl Select for Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { #[doc(hidden)] @@ -48,9 +48,9 @@ where } } -impl Mask +impl Mask where - Element: MaskElement, + T: MaskElement, LaneCount: SupportedLaneCount, { /// Choose lanes from two vectors. diff --git a/crates/core_simd/src/vector.rs b/crates/core_simd/src/vector.rs index 9b6d0a20ed9d..07e8a6c5926c 100644 --- a/crates/core_simd/src/vector.rs +++ b/crates/core_simd/src/vector.rs @@ -11,40 +11,40 @@ pub(crate) mod ptr; use crate::{LaneCount, Mask, MaskElement, SupportedLaneCount}; -/// A SIMD vector of `LANES` elements of type `Element`. +/// A SIMD vector of `LANES` elements of type `T`. #[repr(simd)] -pub struct Simd([Element; LANES]) +pub struct Simd([T; LANES]) where - Element: SimdElement, + T: SimdElement, LaneCount: SupportedLaneCount; -impl Simd +impl Simd where LaneCount: SupportedLaneCount, - Element: SimdElement, + T: SimdElement, { /// Construct a SIMD vector by setting all lanes to the given value. - pub const fn splat(value: Element) -> Self { + pub const fn splat(value: T) -> Self { Self([value; LANES]) } /// Returns an array reference containing the entire SIMD vector. - pub const fn as_array(&self) -> &[Element; LANES] { + pub const fn as_array(&self) -> &[T; LANES] { &self.0 } /// Returns a mutable array reference containing the entire SIMD vector. - pub fn as_mut_array(&mut self) -> &mut [Element; LANES] { + pub fn as_mut_array(&mut self) -> &mut [T; LANES] { &mut self.0 } /// Converts an array to a SIMD vector. - pub const fn from_array(array: [Element; LANES]) -> Self { + pub const fn from_array(array: [T; LANES]) -> Self { Self(array) } /// Converts a SIMD vector to an array. - pub const fn to_array(self) -> [Element; LANES] { + pub const fn to_array(self) -> [T; LANES] { self.0 } @@ -62,7 +62,7 @@ where /// ``` #[must_use] #[inline] - pub fn gather_or(slice: &[Element], idxs: Simd, or: Self) -> Self { + pub fn gather_or(slice: &[T], idxs: Simd, or: Self) -> Self { Self::gather_select(slice, Mask::splat(true), idxs, or) } @@ -79,11 +79,11 @@ where /// ``` #[must_use] #[inline] - pub fn gather_or_default(slice: &[Element], idxs: Simd) -> Self + pub fn gather_or_default(slice: &[T], idxs: Simd) -> Self where - Element: Default, + T: Default, { - Self::gather_or(slice, idxs, Self::splat(Element::default())) + Self::gather_or(slice, idxs, Self::splat(T::default())) } /// SIMD gather: construct a SIMD vector by reading from a slice, using potentially discontiguous indices. @@ -102,7 +102,7 @@ where #[must_use] #[inline] pub fn gather_select( - slice: &[Element], + slice: &[T], mask: Mask, idxs: Simd, or: Self, @@ -129,7 +129,7 @@ where /// assert_eq!(vec, vec![124, 11, 12, 82, 14, 15, 16, 17, 18]); /// ``` #[inline] - pub fn scatter(self, slice: &mut [Element], idxs: Simd) { + pub fn scatter(self, slice: &mut [T], idxs: Simd) { self.scatter_select(slice, Mask::splat(true), idxs) } @@ -150,7 +150,7 @@ where #[inline] pub fn scatter_select( self, - slice: &mut [Element], + slice: &mut [T], mask: Mask, idxs: Simd, ) { @@ -178,16 +178,16 @@ where } } -impl Copy for Simd +impl Copy for Simd where - Element: SimdElement, + T: SimdElement, LaneCount: SupportedLaneCount, { } -impl Clone for Simd +impl Clone for Simd where - Element: SimdElement, + T: SimdElement, LaneCount: SupportedLaneCount, { fn clone(&self) -> Self { @@ -195,21 +195,21 @@ where } } -impl Default for Simd +impl Default for Simd where LaneCount: SupportedLaneCount, - Element: SimdElement + Default, + T: SimdElement + Default, { #[inline] fn default() -> Self { - Self::splat(Element::default()) + Self::splat(T::default()) } } -impl PartialEq for Simd +impl PartialEq for Simd where LaneCount: SupportedLaneCount, - Element: SimdElement + PartialEq, + T: SimdElement + PartialEq, { #[inline] fn eq(&self, other: &Self) -> bool { @@ -218,10 +218,10 @@ where } } -impl PartialOrd for Simd +impl PartialOrd for Simd where LaneCount: SupportedLaneCount, - Element: SimdElement + PartialOrd, + T: SimdElement + PartialOrd, { #[inline] fn partial_cmp(&self, other: &Self) -> Option { @@ -230,17 +230,17 @@ where } } -impl Eq for Simd +impl Eq for Simd where LaneCount: SupportedLaneCount, - Element: SimdElement + Eq, + T: SimdElement + Eq, { } -impl Ord for Simd +impl Ord for Simd where LaneCount: SupportedLaneCount, - Element: SimdElement + Ord, + T: SimdElement + Ord, { #[inline] fn cmp(&self, other: &Self) -> core::cmp::Ordering { @@ -249,10 +249,10 @@ where } } -impl core::hash::Hash for Simd +impl core::hash::Hash for Simd where LaneCount: SupportedLaneCount, - Element: SimdElement + core::hash::Hash, + T: SimdElement + core::hash::Hash, { #[inline] fn hash(&self, state: &mut H) @@ -264,68 +264,68 @@ where } // array references -impl AsRef<[Element; LANES]> for Simd +impl AsRef<[T; LANES]> for Simd where LaneCount: SupportedLaneCount, - Element: SimdElement, + T: SimdElement, { #[inline] - fn as_ref(&self) -> &[Element; LANES] { + fn as_ref(&self) -> &[T; LANES] { &self.0 } } -impl AsMut<[Element; LANES]> for Simd +impl AsMut<[T; LANES]> for Simd where LaneCount: SupportedLaneCount, - Element: SimdElement, + T: SimdElement, { #[inline] - fn as_mut(&mut self) -> &mut [Element; LANES] { + fn as_mut(&mut self) -> &mut [T; LANES] { &mut self.0 } } // slice references -impl AsRef<[Element]> for Simd +impl AsRef<[T]> for Simd where LaneCount: SupportedLaneCount, - Element: SimdElement, + T: SimdElement, { #[inline] - fn as_ref(&self) -> &[Element] { + fn as_ref(&self) -> &[T] { &self.0 } } -impl AsMut<[Element]> for Simd +impl AsMut<[T]> for Simd where LaneCount: SupportedLaneCount, - Element: SimdElement, + T: SimdElement, { #[inline] - fn as_mut(&mut self) -> &mut [Element] { + fn as_mut(&mut self) -> &mut [T] { &mut self.0 } } // vector/array conversion -impl From<[Element; LANES]> for Simd +impl From<[T; LANES]> for Simd where LaneCount: SupportedLaneCount, - Element: SimdElement, + T: SimdElement, { - fn from(array: [Element; LANES]) -> Self { + fn from(array: [T; LANES]) -> Self { Self(array) } } -impl From> for [Element; LANES] +impl From> for [T; LANES] where LaneCount: SupportedLaneCount, - Element: SimdElement, + T: SimdElement, { - fn from(vector: Simd) -> Self { + fn from(vector: Simd) -> Self { vector.to_array() } }