@@ -1342,14 +1342,12 @@ impl<T> [T] {
1342
1342
/// slice. Equivalently, rotates the slice `mid` places to the left
1343
1343
/// or `k = self.len() - mid` places to the right.
1344
1344
///
1345
- /// Rotation by `mid` and rotation by `k` are inverse operations.
1346
- /// The method returns `k`, which is also the new location of
1347
- /// the formerly-first element.
1348
- ///
1349
1345
/// This is a "k-rotation", a permutation in which item `i` moves to
1350
1346
/// position `i + k`, modulo the length of the slice. See _Elements
1351
1347
/// of Programming_ [§10.4][eop].
1352
1348
///
1349
+ /// Rotation by `mid` and rotation by `k` are inverse operations.
1350
+ ///
1353
1351
/// [eop]: https://books.google.com/books?id=CO9ULZGINlsC&pg=PA178&q=k-rotation
1354
1352
///
1355
1353
/// # Panics
@@ -1368,8 +1366,10 @@ impl<T> [T] {
1368
1366
/// #![feature(slice_rotate)]
1369
1367
///
1370
1368
/// let mut a = [1, 2, 3, 4, 5, 6, 7];
1371
- /// let k = a.rotate(2);
1369
+ /// let mid = 2;
1370
+ /// a.rotate(mid);
1372
1371
/// assert_eq!(&a, &[3, 4, 5, 6, 7, 1, 2]);
1372
+ /// let k = a.len() - mid;
1373
1373
/// a.rotate(k);
1374
1374
/// assert_eq!(&a, &[1, 2, 3, 4, 5, 6, 7]);
1375
1375
///
@@ -1388,8 +1388,8 @@ impl<T> [T] {
1388
1388
/// assert_eq!(&v, &[0, 3, 7, 4, 5, 6, 1, 2, 8, 9]);
1389
1389
/// ```
1390
1390
#[ unstable( feature = "slice_rotate" , issue = "41891" ) ]
1391
- pub fn rotate ( & mut self , mid : usize ) -> usize {
1392
- core_slice:: SliceExt :: rotate ( self , mid)
1391
+ pub fn rotate ( & mut self , mid : usize ) {
1392
+ core_slice:: SliceExt :: rotate ( self , mid) ;
1393
1393
}
1394
1394
1395
1395
/// Copies the elements from `src` into `self`.
0 commit comments