File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -733,14 +733,14 @@ impl<T: Clone> ToOwned for [T] {
733
733
fn clone_into ( & self , target : & mut Vec < T > ) {
734
734
// drop anything in target that will not be overwritten
735
735
target. truncate ( self . len ( ) ) ;
736
- let len = target. len ( ) ;
737
-
738
- // reuse the contained values' allocations/resources.
739
- target. clone_from_slice ( & self [ ..len] ) ;
740
736
741
737
// target.len <= self.len due to the truncate above, so the
742
- // slice here is always in-bounds.
743
- target. extend_from_slice ( & self [ len..] ) ;
738
+ // slices here are always in-bounds.
739
+ let ( init, tail) = self . split_at ( target. len ( ) ) ;
740
+
741
+ // reuse the contained values' allocations/resources.
742
+ target. clone_from_slice ( init) ;
743
+ target. extend_from_slice ( tail) ;
744
744
}
745
745
}
746
746
You can’t perform that action at this time.
0 commit comments