@@ -214,6 +214,16 @@ where
214214 /// Rotates the vector such that the first `OFFSET` elements of the slice move to the end
215215 /// while the last `self.len() - OFFSET` elements move to the front. After calling `rotate_elements_left`,
216216 /// 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+ /// ```
217227 #[ inline]
218228 #[ must_use = "method returns a new vector and does not mutate the original inputs" ]
219229 pub fn rotate_elements_left < const OFFSET : usize > ( self ) -> Self {
@@ -238,6 +248,16 @@ where
238248 /// Rotates the vector such that the first `self.len() - OFFSET` elements of the vector move to
239249 /// the end while the last `OFFSET` elements move to the front. After calling `rotate_elements_right`,
240250 /// 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+ /// ```
241261 #[ inline]
242262 #[ must_use = "method returns a new vector and does not mutate the original inputs" ]
243263 pub fn rotate_elements_right < const OFFSET : usize > ( self ) -> Self {
@@ -261,6 +281,16 @@ where
261281
262282 /// Shifts the vector elements to the left by `OFFSET`, filling in with
263283 /// `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+ /// ```
264294 #[ inline]
265295 #[ must_use = "method returns a new vector and does not mutate the original inputs" ]
266296 pub fn shift_elements_left < const OFFSET : usize > ( self , padding : T ) -> Self {
@@ -283,6 +313,16 @@ where
283313
284314 /// Shifts the vector elements to the right by `OFFSET`, filling in with
285315 /// `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+ /// ```
286326 #[ inline]
287327 #[ must_use = "method returns a new vector and does not mutate the original inputs" ]
288328 pub fn shift_elements_right < const OFFSET : usize > ( self , padding : T ) -> Self {
0 commit comments