-
Notifications
You must be signed in to change notification settings - Fork 12.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tracking Issue for iter::repeat_n()
(feature(iter_repeat_n)
)
#104434
Labels
C-tracking-issue
Category: A tracking issue for an RFC or an unstable feature.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
Comments
JohnTitor
pushed a commit
to JohnTitor/rust
that referenced
this issue
Nov 20, 2022
`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` (rust-lang#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 task
thomcc
pushed a commit
to tcdi/postgrestd
that referenced
this issue
Feb 10, 2023
`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` (rust-lang/rust#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
mina86
added a commit
to mina86/rust
that referenced
this issue
Sep 2, 2023
…ith> Repeat iterator always returns the same element and behaves the same way backwards and forwards. Take iterator can trivially implement backwards iteration over Repeat inner iterator by simply doing forwards iteration. DoubleEndedIterator is not currently implemented for Take<Repeat<T>> because Repeat doesn’t implement ExactSizeIterator which is a required bound on DEI implementation for Take. Similarly, since Repeat is an infinite iterator which never stops, Take can trivially know how many elements it’s going to return. This allows implementing ExactSizeIterator on Take<Repeat<T>>. While at it, observe that ExactSizeIterator can also be implemented for Take<RepeatWhile<F>> so add that implementation too. Since in contrast to Repeat, RepeatWhile doesn’t guarante to always return the same value, DoubleEndedIterator isn’t implemented. Those changes render core::iter::repeat_n somewhat redundant. Issue: rust-lang#104434 Issue: rust-lang#104729
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C-tracking-issue
Category: A tracking issue for an RFC or an unstable feature.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
Feature gate:
#![feature(iter_repeat_n)]
This is a tracking issue for the
iter::repeat_n
function and its associatediter::RepeatN
type.This is like
repeat
, but count-limited so it can re-use the buffer when generating the last item.ACP rust-lang/libs-team#120 is still open, but I'm sending a PR for it anyway as part of fixing a bug in
VecDeque
.Public API
Steps / History
doc(hidden)
:VecDeque::resize
should re-use the buffer in the passed-in element #104435iter::repeat_n
from itertools libs-team#120iter::repeat_n
#120045Unresolved Questions
Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩
The text was updated successfully, but these errors were encountered: