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 @@ -735,14 +735,14 @@ impl<T: Clone> ToOwned for [T] {
735735 fn clone_into ( & self , target : & mut Vec < T > ) {
736736 // drop anything in target that will not be overwritten
737737 target. truncate ( self . len ( ) ) ;
738- let len = target. len ( ) ;
739-
740- // reuse the contained values' allocations/resources.
741- target. clone_from_slice ( & self [ ..len] ) ;
742738
743739 // target.len <= self.len due to the truncate above, so the
744- // slice here is always in-bounds.
745- target. extend_from_slice ( & self [ len..] ) ;
740+ // slices here are always in-bounds.
741+ let ( init, tail) = self . split_at ( target. len ( ) ) ;
742+
743+ // reuse the contained values' allocations/resources.
744+ target. clone_from_slice ( init) ;
745+ target. extend_from_slice ( tail) ;
746746 }
747747}
748748
You can’t perform that action at this time.
0 commit comments