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] {
733733 fn clone_into ( & self , target : & mut Vec < T > ) {
734734 // drop anything in target that will not be overwritten
735735 target. truncate ( self . len ( ) ) ;
736- let len = target. len ( ) ;
737-
738- // reuse the contained values' allocations/resources.
739- target. clone_from_slice ( & self [ ..len] ) ;
740736
741737 // 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) ;
744744 }
745745}
746746
You can’t perform that action at this time.
0 commit comments