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