]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #107424 - bpeel:clone-into-from-share-code, r=scottmcm
authorMatthias Krüger <matthias.krueger@famsik.de>
Mon, 30 Jan 2023 16:50:10 +0000 (17:50 +0100)
committerGitHub <noreply@github.com>
Mon, 30 Jan 2023 16:50:10 +0000 (17:50 +0100)
Make Vec::clone_from and slice::clone_into share the same code

In the past, `Vec::clone_from` was implemented using `slice::clone_into`. The code from `clone_into` was later duplicated into `clone_from` in 8725e4c337, which is the commit that adds custom allocator support to Vec. Presumably this was done because the `slice::clone_into` method only works for vecs with the default allocator so it would have the wrong type to clone into `Vec<T, A>`.

Later on in 361398009be6 the code for the two methods diverged because the `Vec::clone_from` version gained a specialization to optimize the case when T is Copy. In order to reduce code duplication and make them both be able to take advantage of this specialization, this PR moves the specialization into the slice module and makes vec use it again.


Trivial merge