]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #104435 - scottmcm:iter-repeat-n, r=thomcc
authorYuki Okushi <huyuumi.dev+love@gmail.com>
Sun, 20 Nov 2022 04:15:59 +0000 (13:15 +0900)
committerGitHub <noreply@github.com>
Sun, 20 Nov 2022 04:15:59 +0000 (13:15 +0900)
`VecDeque::resize` should re-use the buffer in the passed-in element

Today it always copies it for *every* appended element, but one of those clones is avoidable.

This adds `iter::repeat_n` (https://github.com/rust-lang/rust/issues/104434) as the primitive needed to do this.  If this PR is acceptable, I'll also use this in `Vec` rather than its custom `ExtendElement` type & infrastructure that is harder to share between multiple different containers:

https://github.com/rust-lang/rust/blob/101e1822c3e54e63996c8aaa014d55716f3937eb/library/alloc/src/vec/mod.rs#L2479-L2492

1  2 
library/core/tests/lib.rs

Simple merge