Closed
Description
Feature gate: #![feature(iter_repeat_n)]
This is a tracking issue for the iter::repeat_n
function and its associated iter::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
// core::iter
fn repeat_n<T>(element: T, count: usize) -> RepeatN<T>;
pub struct RepeatN<T>(…);
impl<T: Clone> Iterator for RepeatN<T> { … }
impl<T: Clone> DoubleEndedIterator for RepeatN<T> { … }
impl<T: Clone> ExactSizeIterator for RepeatN<T> { … }
impl<T: Clone> FusedIterator for RepeatN<T> { … }
impl<T: Clone> TrustedLen for RepeatN<T> { … }
Steps / History
- Implementation as
doc(hidden)
:VecDeque::resize
should re-use the buffer in the passed-in element #104435 - ACP: ACP: Uplift
iter::repeat_n
from itertools libs-team#120 - Un-hidden: Un-hide
iter::repeat_n
#120045 - Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- None yet.