Fixups for sync
- Fix LANES over-replace - Bring in traits - Use less inference-heavy types
This commit is contained in:
parent
50416fcc2c
commit
8f50a17c37
1 changed files with 7 additions and 6 deletions
|
@ -2,6 +2,7 @@ use crate::simd::{
|
||||||
intrinsics, LaneCount, Mask, MaskElement, SimdCast, SimdCastPtr, SimdConstPtr, SimdMutPtr,
|
intrinsics, LaneCount, Mask, MaskElement, SimdCast, SimdCastPtr, SimdConstPtr, SimdMutPtr,
|
||||||
SimdPartialOrd, SupportedLaneCount, Swizzle,
|
SimdPartialOrd, SupportedLaneCount, Swizzle,
|
||||||
};
|
};
|
||||||
|
use core::convert::{TryFrom, TryInto};
|
||||||
|
|
||||||
/// A SIMD vector with the shape of `[T; N]` but the operations of `T`.
|
/// A SIMD vector with the shape of `[T; N]` but the operations of `T`.
|
||||||
///
|
///
|
||||||
|
@ -109,7 +110,7 @@ where
|
||||||
T: SimdElement,
|
T: SimdElement,
|
||||||
{
|
{
|
||||||
/// Number of elements in this vector.
|
/// 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.
|
/// Returns the number of elements in this SIMD vector.
|
||||||
///
|
///
|
||||||
|
@ -122,7 +123,7 @@ where
|
||||||
/// assert_eq!(v.lanes(), 4);
|
/// assert_eq!(v.lanes(), 4);
|
||||||
/// ```
|
/// ```
|
||||||
pub const fn lanes(&self) -> usize {
|
pub const fn lanes(&self) -> usize {
|
||||||
Self::N
|
Self::LANES
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Constructs a new SIMD vector with all elements set to the given value.
|
/// Constructs a new SIMD vector with all elements set to the given value.
|
||||||
|
@ -260,7 +261,7 @@ where
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn from_slice(slice: &[T]) -> Self {
|
pub const fn from_slice(slice: &[T]) -> Self {
|
||||||
assert!(
|
assert!(
|
||||||
slice.len() >= Self::N,
|
slice.len() >= Self::LANES,
|
||||||
"slice length must be at least the number of elements"
|
"slice length must be at least the number of elements"
|
||||||
);
|
);
|
||||||
// SAFETY: We just checked that the slice contains
|
// SAFETY: We just checked that the slice contains
|
||||||
|
@ -288,7 +289,7 @@ where
|
||||||
/// ```
|
/// ```
|
||||||
pub fn copy_to_slice(self, slice: &mut [T]) {
|
pub fn copy_to_slice(self, slice: &mut [T]) {
|
||||||
assert!(
|
assert!(
|
||||||
slice.len() >= Self::N,
|
slice.len() >= Self::LANES,
|
||||||
"slice length must be at least the number of elements"
|
"slice length must be at least the number of elements"
|
||||||
);
|
);
|
||||||
// SAFETY: We just checked that the slice contains
|
// SAFETY: We just checked that the slice contains
|
||||||
|
@ -883,7 +884,7 @@ where
|
||||||
{
|
{
|
||||||
type Error = core::array::TryFromSliceError;
|
type Error = core::array::TryFromSliceError;
|
||||||
|
|
||||||
fn try_from(slice: &[T]) -> Result<Self, Self::Error> {
|
fn try_from(slice: &[T]) -> Result<Self, core::array::TryFromSliceError> {
|
||||||
Ok(Self::from_array(slice.try_into()?))
|
Ok(Self::from_array(slice.try_into()?))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -895,7 +896,7 @@ where
|
||||||
{
|
{
|
||||||
type Error = core::array::TryFromSliceError;
|
type Error = core::array::TryFromSliceError;
|
||||||
|
|
||||||
fn try_from(slice: &mut [T]) -> Result<Self, Self::Error> {
|
fn try_from(slice: &mut [T]) -> Result<Self, core::array::TryFromSliceError> {
|
||||||
Ok(Self::from_array(slice.try_into()?))
|
Ok(Self::from_array(slice.try_into()?))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue