Skip to content

Commit 57e67c9

Browse files
authored
add doctests for shuffle (#130)
* add shuffle doctests/examples
1 parent 68393aa commit 57e67c9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

crates/core_simd/src/permute.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ macro_rules! impl_shuffle_lane {
99
/// Some SIMD shuffle instructions can be quite slow, so avoiding them by loading data
1010
/// into the desired patterns in advance is preferred, but shuffles are still faster
1111
/// than storing and reloading from memory.
12+
///
13+
/// ```
14+
/// # use core_simd::*;
15+
// let a = f32x4::from_array([1.0, 2.0, 3.0, 4.0]);
16+
// let b = f32x4::from_array([5.0, 6.0, 7.0, 8.0]);
17+
// const IDXS: [u32; 4] = [4,0,3,7];
18+
// let c = f32x4::shuffle::<IDXS>(a,b);
19+
// assert_eq!(f32x4::from_array([5.0, 1.0, 4.0, 8.0]), c);
20+
/// ```
1221
#[inline]
1322
pub fn shuffle<const IDX: [u32; $n]>(self, second: Self) -> Self {
1423
unsafe { crate::intrinsics::$fn(self, second, IDX) }

0 commit comments

Comments
 (0)