@@ -987,7 +987,6 @@ impl<'a> IoSliceMut<'a> {
987
987
/// #![feature(io_slice_advance)]
988
988
///
989
989
/// use std::io::IoSliceMut;
990
- /// use std::mem;
991
990
/// use std::ops::Deref;
992
991
///
993
992
/// let mut buf1 = [1; 8];
@@ -1000,7 +999,7 @@ impl<'a> IoSliceMut<'a> {
1000
999
/// ][..];
1001
1000
///
1002
1001
/// // Mark 10 bytes as read.
1003
- /// bufs = IoSliceMut::advance(mem::replace(&mut bufs, &mut []) , 10);
1002
+ /// bufs = IoSliceMut::advance(bufs, 10);
1004
1003
/// assert_eq!(bufs[0].deref(), [2; 14].as_ref());
1005
1004
/// assert_eq!(bufs[1].deref(), [3; 8].as_ref());
1006
1005
/// ```
@@ -1090,20 +1089,19 @@ impl<'a> IoSlice<'a> {
1090
1089
/// #![feature(io_slice_advance)]
1091
1090
///
1092
1091
/// use std::io::IoSlice;
1093
- /// use std::mem;
1094
1092
/// use std::ops::Deref;
1095
1093
///
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];
1099
1097
/// 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),
1103
1101
/// ][..];
1104
1102
///
1105
1103
/// // Mark 10 bytes as written.
1106
- /// bufs = IoSlice::advance(mem::replace(&mut bufs, &mut []) , 10);
1104
+ /// bufs = IoSlice::advance(bufs, 10);
1107
1105
/// assert_eq!(bufs[0].deref(), [2; 14].as_ref());
1108
1106
/// assert_eq!(bufs[1].deref(), [3; 8].as_ref());
1109
1107
#[ unstable( feature = "io_slice_advance" , issue = "62726" ) ]
@@ -2415,7 +2413,6 @@ mod tests {
2415
2413
use crate :: cmp;
2416
2414
use crate :: io:: prelude:: * ;
2417
2415
use crate :: io:: { self , IoSlice , IoSliceMut } ;
2418
- use crate :: mem;
2419
2416
use crate :: ops:: Deref ;
2420
2417
2421
2418
#[ test]
@@ -2731,26 +2728,26 @@ mod tests {
2731
2728
] [ ..] ;
2732
2729
2733
2730
// Only in a single buffer..
2734
- bufs = IoSliceMut :: advance ( mem :: replace ( & mut bufs, & mut [ ] ) , 1 ) ;
2731
+ bufs = IoSliceMut :: advance ( bufs, 1 ) ;
2735
2732
assert_eq ! ( bufs[ 0 ] . deref( ) , [ 1 ; 7 ] . as_ref( ) ) ;
2736
2733
assert_eq ! ( bufs[ 1 ] . deref( ) , [ 2 ; 16 ] . as_ref( ) ) ;
2737
2734
assert_eq ! ( bufs[ 2 ] . deref( ) , [ 3 ; 8 ] . as_ref( ) ) ;
2738
2735
2739
2736
// Removing a buffer, leaving others as is.
2740
- bufs = IoSliceMut :: advance ( mem :: replace ( & mut bufs, & mut [ ] ) , 7 ) ;
2737
+ bufs = IoSliceMut :: advance ( bufs, 7 ) ;
2741
2738
assert_eq ! ( bufs[ 0 ] . deref( ) , [ 2 ; 16 ] . as_ref( ) ) ;
2742
2739
assert_eq ! ( bufs[ 1 ] . deref( ) , [ 3 ; 8 ] . as_ref( ) ) ;
2743
2740
2744
2741
// 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 ) ;
2746
2743
assert_eq ! ( bufs[ 0 ] . deref( ) , [ 3 ; 6 ] . as_ref( ) ) ;
2747
2744
}
2748
2745
2749
2746
#[ test]
2750
2747
fn io_slice_mut_advance_empty_slice ( ) {
2751
- let mut empty_bufs = & mut [ ] [ ..] ;
2748
+ let empty_bufs = & mut [ ] [ ..] ;
2752
2749
// Shouldn't panic.
2753
- IoSliceMut :: advance ( & mut empty_bufs, 1 ) ;
2750
+ IoSliceMut :: advance ( empty_bufs, 1 ) ;
2754
2751
}
2755
2752
2756
2753
#[ test]
@@ -2759,48 +2756,48 @@ mod tests {
2759
2756
let mut bufs = & mut [ IoSliceMut :: new ( & mut buf1) ] [ ..] ;
2760
2757
2761
2758
// Going beyond the total length should be ok.
2762
- bufs = IoSliceMut :: advance ( mem :: replace ( & mut bufs, & mut [ ] ) , 9 ) ;
2759
+ bufs = IoSliceMut :: advance ( bufs, 9 ) ;
2763
2760
assert ! ( bufs. is_empty( ) ) ;
2764
2761
}
2765
2762
2766
2763
#[ test]
2767
2764
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 ] ;
2771
2768
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) ] [ ..] ;
2773
2770
2774
2771
// Only in a single buffer..
2775
- bufs = IoSlice :: advance ( mem :: replace ( & mut bufs, & mut [ ] ) , 1 ) ;
2772
+ bufs = IoSlice :: advance ( bufs, 1 ) ;
2776
2773
assert_eq ! ( bufs[ 0 ] . deref( ) , [ 1 ; 7 ] . as_ref( ) ) ;
2777
2774
assert_eq ! ( bufs[ 1 ] . deref( ) , [ 2 ; 16 ] . as_ref( ) ) ;
2778
2775
assert_eq ! ( bufs[ 2 ] . deref( ) , [ 3 ; 8 ] . as_ref( ) ) ;
2779
2776
2780
2777
// Removing a buffer, leaving others as is.
2781
- bufs = IoSlice :: advance ( mem :: replace ( & mut bufs, & mut [ ] ) , 7 ) ;
2778
+ bufs = IoSlice :: advance ( bufs, 7 ) ;
2782
2779
assert_eq ! ( bufs[ 0 ] . deref( ) , [ 2 ; 16 ] . as_ref( ) ) ;
2783
2780
assert_eq ! ( bufs[ 1 ] . deref( ) , [ 3 ; 8 ] . as_ref( ) ) ;
2784
2781
2785
2782
// 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 ) ;
2787
2784
assert_eq ! ( bufs[ 0 ] . deref( ) , [ 3 ; 6 ] . as_ref( ) ) ;
2788
2785
}
2789
2786
2790
2787
#[ test]
2791
2788
fn io_slice_advance_empty_slice ( ) {
2792
- let mut empty_bufs = & mut [ ] [ ..] ;
2789
+ let empty_bufs = & mut [ ] [ ..] ;
2793
2790
// Shouldn't panic.
2794
- IoSlice :: advance ( & mut empty_bufs, 1 ) ;
2791
+ IoSlice :: advance ( empty_bufs, 1 ) ;
2795
2792
}
2796
2793
2797
2794
#[ test]
2798
2795
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) ] [ ..] ;
2801
2798
2802
2799
// Going beyond the total length should be ok.
2803
- bufs = IoSlice :: advance ( mem :: replace ( & mut bufs, & mut [ ] ) , 9 ) ;
2800
+ bufs = IoSlice :: advance ( bufs, 9 ) ;
2804
2801
assert ! ( bufs. is_empty( ) ) ;
2805
2802
}
2806
2803
}
0 commit comments