]> git.lizzy.rs Git - rust.git/commit
vec: Use SpecCloneIntoVec::clone_into to implement Vec::clone_from
authorNeil Roberts <bpeeluk@yahoo.co.uk>
Sat, 28 Jan 2023 13:52:31 +0000 (14:52 +0100)
committerNeil Roberts <bpeeluk@yahoo.co.uk>
Sat, 28 Jan 2023 19:37:01 +0000 (20:37 +0100)
commita34f11c006936f0935c0f3484f9a292901d0eade
tree05f4f78b355e27cbec00b0fdb00a33ec36ba7c23
parentba80c662f448c69cbd184d18630b8824f0169b2e
vec: Use SpecCloneIntoVec::clone_into to implement Vec::clone_from

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 only works
for vecs with the default allocator so it would have the wrong type to
clone into Vec<T, A>.

Now that the clone_into implementation is moved out into a specializable
trait anyway we might as well use that to share the code between the two
methods.
library/alloc/src/vec/mod.rs