Skip to content

Commit 8f50a17

Browse files
Fixups for sync
- Fix LANES over-replace - Bring in traits - Use less inference-heavy types
1 parent 50416fc commit 8f50a17

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

crates/core_simd/src/vector.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::simd::{
22
intrinsics, LaneCount, Mask, MaskElement, SimdCast, SimdCastPtr, SimdConstPtr, SimdMutPtr,
33
SimdPartialOrd, SupportedLaneCount, Swizzle,
44
};
5+
use core::convert::{TryFrom, TryInto};
56

67
/// A SIMD vector with the shape of `[T; N]` but the operations of `T`.
78
///
@@ -109,7 +110,7 @@ where
109110
T: SimdElement,
110111
{
111112
/// Number of elements in this vector.
112-
pub const N: usize = N;
113+
pub const LANES: usize = N;
113114

114115
/// Returns the number of elements in this SIMD vector.
115116
///
@@ -122,7 +123,7 @@ where
122123
/// assert_eq!(v.lanes(), 4);
123124
/// ```
124125
pub const fn lanes(&self) -> usize {
125-
Self::N
126+
Self::LANES
126127
}
127128

128129
/// Constructs a new SIMD vector with all elements set to the given value.
@@ -260,7 +261,7 @@ where
260261
#[must_use]
261262
pub const fn from_slice(slice: &[T]) -> Self {
262263
assert!(
263-
slice.len() >= Self::N,
264+
slice.len() >= Self::LANES,
264265
"slice length must be at least the number of elements"
265266
);
266267
// SAFETY: We just checked that the slice contains
@@ -288,7 +289,7 @@ where
288289
/// ```
289290
pub fn copy_to_slice(self, slice: &mut [T]) {
290291
assert!(
291-
slice.len() >= Self::N,
292+
slice.len() >= Self::LANES,
292293
"slice length must be at least the number of elements"
293294
);
294295
// SAFETY: We just checked that the slice contains
@@ -883,7 +884,7 @@ where
883884
{
884885
type Error = core::array::TryFromSliceError;
885886

886-
fn try_from(slice: &[T]) -> Result<Self, Self::Error> {
887+
fn try_from(slice: &[T]) -> Result<Self, core::array::TryFromSliceError> {
887888
Ok(Self::from_array(slice.try_into()?))
888889
}
889890
}
@@ -895,7 +896,7 @@ where
895896
{
896897
type Error = core::array::TryFromSliceError;
897898

898-
fn try_from(slice: &mut [T]) -> Result<Self, Self::Error> {
899+
fn try_from(slice: &mut [T]) -> Result<Self, core::array::TryFromSliceError> {
899900
Ok(Self::from_array(slice.try_into()?))
900901
}
901902
}

0 commit comments

Comments
 (0)