Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f178dda

Browse files
committed
Add as_slice/as_mut_slice to Vector
1 parent c077bf3 commit f178dda

File tree

1 file changed

+16
-1
lines changed
  • crates/core_simd/src/vector

1 file changed

+16
-1
lines changed

crates/core_simd/src/vector/mod.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ pub trait Vector: sealed::Sealed {
3131
#[must_use]
3232
fn splat(val: Self::Scalar) -> Self;
3333

34+
/// Returns a slice containing the entire SIMD vector.
35+
fn as_slice(&self) -> &[Self::Scalar];
36+
37+
/// Returns a mutable slice containing the entire SIMD vector.
38+
fn as_mut_slice(&mut self) -> &mut [Self::Scalar];
3439
}
3540

3641
macro_rules! impl_vector_for {
@@ -53,7 +58,17 @@ macro_rules! impl_vector_for {
5358

5459
#[inline]
5560
fn splat(val: Self::Scalar) -> Self {
56-
[val; $lanes].into()
61+
Self::splat(val)
62+
}
63+
64+
#[inline]
65+
fn as_slice(&self) -> &[Self::Scalar] {
66+
self.as_slice()
67+
}
68+
69+
#[inline]
70+
fn as_mut_slice(&mut self) -> &mut [Self::Scalar] {
71+
self.as_mut_slice()
5772
}
5873
}
5974
};

0 commit comments

Comments
 (0)