@@ -214,6 +214,17 @@ where
214
214
/// Rotates the vector such that the first `OFFSET` elements of the slice move to the end
215
215
/// while the last `self.len() - OFFSET` elements move to the front. After calling `rotate_elements_left`,
216
216
/// the element previously at index `OFFSET` will become the first element in the slice.
217
+ /// ```
218
+ /// # #![feature(portable_simd)]
219
+ /// # #[cfg(feature = "as_crate")] use core_simd::simd::Simd;
220
+ /// # #[cfg(not(feature = "as_crate"))] use core::simd::Simd;
221
+ /// let a = Simd::from_array([0, 1, 2, 3]);
222
+ /// let x = a.rotate_elements_left::<3>();
223
+ /// assert_eq!(x.to_array(), [3, 0, 1, 2]);
224
+ ///
225
+ /// let y = a.rotate_elements_left::<7>();
226
+ /// assert_eq!(y.to_array(), [3, 0, 1, 2]);
227
+ /// ```
217
228
#[ inline]
218
229
#[ must_use = "method returns a new vector and does not mutate the original inputs" ]
219
230
pub fn rotate_elements_left < const OFFSET : usize > ( self ) -> Self {
@@ -238,6 +249,17 @@ where
238
249
/// Rotates the vector such that the first `self.len() - OFFSET` elements of the vector move to
239
250
/// the end while the last `OFFSET` elements move to the front. After calling `rotate_elements_right`,
240
251
/// the element previously at index `self.len() - OFFSET` will become the first element in the slice.
252
+ /// ```
253
+ /// # #![feature(portable_simd)]
254
+ /// # #[cfg(feature = "as_crate")] use core_simd::simd::Simd;
255
+ /// # #[cfg(not(feature = "as_crate"))] use core::simd::Simd;
256
+ /// let a = Simd::from_array([0, 1, 2, 3]);
257
+ /// let x = a.rotate_elements_right::<3>();
258
+ /// assert_eq!(x.to_array(), [1, 2, 3, 0]);
259
+ ///
260
+ /// let y = a.rotate_elements_right::<7>();
261
+ /// assert_eq!(y.to_array(), [1, 2, 3, 0]);
262
+ /// ```
241
263
#[ inline]
242
264
#[ must_use = "method returns a new vector and does not mutate the original inputs" ]
243
265
pub fn rotate_elements_right < const OFFSET : usize > ( self ) -> Self {
@@ -261,6 +283,17 @@ where
261
283
262
284
/// Shifts the vector elements to the left by `OFFSET`, filling in with
263
285
/// `padding` from the right.
286
+ /// ```
287
+ /// # #![feature(portable_simd)]
288
+ /// # #[cfg(feature = "as_crate")] use core_simd::simd::Simd;
289
+ /// # #[cfg(not(feature = "as_crate"))] use core::simd::Simd;
290
+ /// let a = Simd::from_array([0, 1, 2, 3]);
291
+ /// let x = a.shift_elements_left::<3>(255);
292
+ /// assert_eq!(x.to_array(), [3, 255, 255, 255]);
293
+ ///
294
+ /// let y = a.shift_elements_left::<7>(255);
295
+ /// assert_eq!(y.to_array(), [255, 255, 255, 255]);
296
+ /// ```
264
297
#[ inline]
265
298
#[ must_use = "method returns a new vector and does not mutate the original inputs" ]
266
299
pub fn shift_elements_left < const OFFSET : usize > ( self , padding : T ) -> Self {
@@ -283,6 +316,17 @@ where
283
316
284
317
/// Shifts the vector elements to the right by `OFFSET`, filling in with
285
318
/// `padding` from the left.
319
+ /// ```
320
+ /// # #![feature(portable_simd)]
321
+ /// # #[cfg(feature = "as_crate")] use core_simd::simd::Simd;
322
+ /// # #[cfg(not(feature = "as_crate"))] use core::simd::Simd;
323
+ /// let a = Simd::from_array([0, 1, 2, 3]);
324
+ /// let x = a.shift_elements_right::<3>(255);
325
+ /// assert_eq!(x.to_array(), [255, 255, 255, 0]);
326
+ ///
327
+ /// let y = a.shift_elements_right::<7>(255);
328
+ /// assert_eq!(y.to_array(), [255, 255, 255, 255]);
329
+ /// ```
286
330
#[ inline]
287
331
#[ must_use = "method returns a new vector and does not mutate the original inputs" ]
288
332
pub fn shift_elements_right < const OFFSET : usize > ( self , padding : T ) -> Self {
0 commit comments