@@ -987,7 +987,6 @@ impl<'a> IoSliceMut<'a> {
987987 /// #![feature(io_slice_advance)]
988988 ///
989989 /// use std::io::IoSliceMut;
990- /// use std::mem;
991990 /// use std::ops::Deref;
992991 ///
993992 /// let mut buf1 = [1; 8];
@@ -1000,7 +999,7 @@ impl<'a> IoSliceMut<'a> {
1000999 /// ][..];
10011000 ///
10021001 /// // Mark 10 bytes as read.
1003- /// bufs = IoSliceMut::advance(mem::replace(&mut bufs, &mut []) , 10);
1002+ /// bufs = IoSliceMut::advance(bufs, 10);
10041003 /// assert_eq!(bufs[0].deref(), [2; 14].as_ref());
10051004 /// assert_eq!(bufs[1].deref(), [3; 8].as_ref());
10061005 /// ```
@@ -1090,20 +1089,19 @@ impl<'a> IoSlice<'a> {
10901089 /// #![feature(io_slice_advance)]
10911090 ///
10921091 /// use std::io::IoSlice;
1093- /// use std::mem;
10941092 /// use std::ops::Deref;
10951093 ///
1096- /// let mut buf1 = [1; 8];
1097- /// let mut buf2 = [2; 16];
1098- /// let mut buf3 = [3; 8];
1094+ /// let buf1 = [1; 8];
1095+ /// let buf2 = [2; 16];
1096+ /// let buf3 = [3; 8];
10991097 /// let mut bufs = &mut [
1100- /// IoSlice::new(&mut buf1),
1101- /// IoSlice::new(&mut buf2),
1102- /// IoSlice::new(&mut buf3),
1098+ /// IoSlice::new(&buf1),
1099+ /// IoSlice::new(&buf2),
1100+ /// IoSlice::new(&buf3),
11031101 /// ][..];
11041102 ///
11051103 /// // Mark 10 bytes as written.
1106- /// bufs = IoSlice::advance(mem::replace(&mut bufs, &mut []) , 10);
1104+ /// bufs = IoSlice::advance(bufs, 10);
11071105 /// assert_eq!(bufs[0].deref(), [2; 14].as_ref());
11081106 /// assert_eq!(bufs[1].deref(), [3; 8].as_ref());
11091107 #[ unstable( feature = "io_slice_advance" , issue = "62726" ) ]
@@ -2415,7 +2413,6 @@ mod tests {
24152413 use crate :: cmp;
24162414 use crate :: io:: prelude:: * ;
24172415 use crate :: io:: { self , IoSlice , IoSliceMut } ;
2418- use crate :: mem;
24192416 use crate :: ops:: Deref ;
24202417
24212418 #[ test]
@@ -2731,26 +2728,26 @@ mod tests {
27312728 ] [ ..] ;
27322729
27332730 // Only in a single buffer..
2734- bufs = IoSliceMut :: advance ( mem :: replace ( & mut bufs, & mut [ ] ) , 1 ) ;
2731+ bufs = IoSliceMut :: advance ( bufs, 1 ) ;
27352732 assert_eq ! ( bufs[ 0 ] . deref( ) , [ 1 ; 7 ] . as_ref( ) ) ;
27362733 assert_eq ! ( bufs[ 1 ] . deref( ) , [ 2 ; 16 ] . as_ref( ) ) ;
27372734 assert_eq ! ( bufs[ 2 ] . deref( ) , [ 3 ; 8 ] . as_ref( ) ) ;
27382735
27392736 // Removing a buffer, leaving others as is.
2740- bufs = IoSliceMut :: advance ( mem :: replace ( & mut bufs, & mut [ ] ) , 7 ) ;
2737+ bufs = IoSliceMut :: advance ( bufs, 7 ) ;
27412738 assert_eq ! ( bufs[ 0 ] . deref( ) , [ 2 ; 16 ] . as_ref( ) ) ;
27422739 assert_eq ! ( bufs[ 1 ] . deref( ) , [ 3 ; 8 ] . as_ref( ) ) ;
27432740
27442741 // Removing a buffer and removing from the next buffer.
2745- bufs = IoSliceMut :: advance ( mem :: replace ( & mut bufs, & mut [ ] ) , 18 ) ;
2742+ bufs = IoSliceMut :: advance ( bufs, 18 ) ;
27462743 assert_eq ! ( bufs[ 0 ] . deref( ) , [ 3 ; 6 ] . as_ref( ) ) ;
27472744 }
27482745
27492746 #[ test]
27502747 fn io_slice_mut_advance_empty_slice ( ) {
2751- let mut empty_bufs = & mut [ ] [ ..] ;
2748+ let empty_bufs = & mut [ ] [ ..] ;
27522749 // Shouldn't panic.
2753- IoSliceMut :: advance ( & mut empty_bufs, 1 ) ;
2750+ IoSliceMut :: advance ( empty_bufs, 1 ) ;
27542751 }
27552752
27562753 #[ test]
@@ -2759,48 +2756,48 @@ mod tests {
27592756 let mut bufs = & mut [ IoSliceMut :: new ( & mut buf1) ] [ ..] ;
27602757
27612758 // Going beyond the total length should be ok.
2762- bufs = IoSliceMut :: advance ( mem :: replace ( & mut bufs, & mut [ ] ) , 9 ) ;
2759+ bufs = IoSliceMut :: advance ( bufs, 9 ) ;
27632760 assert ! ( bufs. is_empty( ) ) ;
27642761 }
27652762
27662763 #[ test]
27672764 fn io_slice_advance ( ) {
2768- let mut buf1 = [ 1 ; 8 ] ;
2769- let mut buf2 = [ 2 ; 16 ] ;
2770- let mut buf3 = [ 3 ; 8 ] ;
2765+ let buf1 = [ 1 ; 8 ] ;
2766+ let buf2 = [ 2 ; 16 ] ;
2767+ let buf3 = [ 3 ; 8 ] ;
27712768 let mut bufs =
2772- & mut [ IoSlice :: new ( & mut buf1) , IoSlice :: new ( & mut buf2) , IoSlice :: new ( & mut buf3) ] [ ..] ;
2769+ & mut [ IoSlice :: new ( & buf1) , IoSlice :: new ( & buf2) , IoSlice :: new ( & buf3) ] [ ..] ;
27732770
27742771 // Only in a single buffer..
2775- bufs = IoSlice :: advance ( mem :: replace ( & mut bufs, & mut [ ] ) , 1 ) ;
2772+ bufs = IoSlice :: advance ( bufs, 1 ) ;
27762773 assert_eq ! ( bufs[ 0 ] . deref( ) , [ 1 ; 7 ] . as_ref( ) ) ;
27772774 assert_eq ! ( bufs[ 1 ] . deref( ) , [ 2 ; 16 ] . as_ref( ) ) ;
27782775 assert_eq ! ( bufs[ 2 ] . deref( ) , [ 3 ; 8 ] . as_ref( ) ) ;
27792776
27802777 // Removing a buffer, leaving others as is.
2781- bufs = IoSlice :: advance ( mem :: replace ( & mut bufs, & mut [ ] ) , 7 ) ;
2778+ bufs = IoSlice :: advance ( bufs, 7 ) ;
27822779 assert_eq ! ( bufs[ 0 ] . deref( ) , [ 2 ; 16 ] . as_ref( ) ) ;
27832780 assert_eq ! ( bufs[ 1 ] . deref( ) , [ 3 ; 8 ] . as_ref( ) ) ;
27842781
27852782 // Removing a buffer and removing from the next buffer.
2786- bufs = IoSlice :: advance ( mem :: replace ( & mut bufs, & mut [ ] ) , 18 ) ;
2783+ bufs = IoSlice :: advance ( bufs, 18 ) ;
27872784 assert_eq ! ( bufs[ 0 ] . deref( ) , [ 3 ; 6 ] . as_ref( ) ) ;
27882785 }
27892786
27902787 #[ test]
27912788 fn io_slice_advance_empty_slice ( ) {
2792- let mut empty_bufs = & mut [ ] [ ..] ;
2789+ let empty_bufs = & mut [ ] [ ..] ;
27932790 // Shouldn't panic.
2794- IoSlice :: advance ( & mut empty_bufs, 1 ) ;
2791+ IoSlice :: advance ( empty_bufs, 1 ) ;
27952792 }
27962793
27972794 #[ test]
27982795 fn io_slice_advance_beyond_total_length ( ) {
2799- let mut buf1 = [ 1 ; 8 ] ;
2800- let mut bufs = & mut [ IoSlice :: new ( & mut buf1) ] [ ..] ;
2796+ let buf1 = [ 1 ; 8 ] ;
2797+ let mut bufs = & mut [ IoSlice :: new ( & buf1) ] [ ..] ;
28012798
28022799 // Going beyond the total length should be ok.
2803- bufs = IoSlice :: advance ( mem :: replace ( & mut bufs, & mut [ ] ) , 9 ) ;
2800+ bufs = IoSlice :: advance ( bufs, 9 ) ;
28042801 assert ! ( bufs. is_empty( ) ) ;
28052802 }
28062803}
0 commit comments