File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 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> {
765765 unsafe {
766766 // set self.vec length's to start, to be safe in case Drain is leaked
767767 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) ;
770773 Drain {
771774 tail_start : end,
772775 tail_len : len - end,
773- iter : range_slice. iter ( ) ,
776+ iter : range_slice. iter_mut ( ) ,
774777 vec : self as * mut _ ,
775- _marker : PhantomData ,
776778 }
777779 }
778780 }
@@ -1832,9 +1834,8 @@ pub struct Drain<'a, T: 'a> {
18321834 /// Length of tail
18331835 tail_len : usize ,
18341836 /// Current remaining range to remove
1835- iter : slice:: Iter < ' a , T > ,
1837+ iter : slice:: IterMut < ' a , T > ,
18361838 vec : * mut Vec < T > ,
1837- _marker : PhantomData < & ' a mut Vec < T > > ,
18381839}
18391840
18401841unsafe impl < ' a , T : Sync > Sync for Drain < ' a , T > { }
You can’t perform that action at this time.
0 commit comments