File tree 1 file changed +7
-6
lines changed
1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -765,14 +765,16 @@ impl<T> Vec<T> {
765
765
unsafe {
766
766
// set self.vec length's to start, to be safe in case Drain is leaked
767
767
self . set_len ( start) ;
768
- let range_slice = slice:: from_raw_parts ( self . as_ptr ( ) . offset ( start as isize ) ,
769
- end - start) ;
768
+ // Use the borrow in the IterMut to indicate borrowing behavior of the
769
+ // whole Drain iterator (like &mut T).
770
+ let range_slice = slice:: from_raw_parts_mut (
771
+ self . as_mut_ptr ( ) . offset ( start as isize ) ,
772
+ end - start) ;
770
773
Drain {
771
774
tail_start : end,
772
775
tail_len : len - end,
773
- iter : range_slice. iter ( ) ,
776
+ iter : range_slice. iter_mut ( ) ,
774
777
vec : self as * mut _ ,
775
- _marker : PhantomData ,
776
778
}
777
779
}
778
780
}
@@ -1832,9 +1834,8 @@ pub struct Drain<'a, T: 'a> {
1832
1834
/// Length of tail
1833
1835
tail_len : usize ,
1834
1836
/// Current remaining range to remove
1835
- iter : slice:: Iter < ' a , T > ,
1837
+ iter : slice:: IterMut < ' a , T > ,
1836
1838
vec : * mut Vec < T > ,
1837
- _marker : PhantomData < & ' a mut Vec < T > > ,
1838
1839
}
1839
1840
1840
1841
unsafe impl < ' a , T : Sync > Sync for Drain < ' a , T > { }
You can’t perform that action at this time.
0 commit comments