about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
diff options
context:
space:
mode:
authorMichal Nazarewicz <mina86@mina86.com>2023-01-16 17:56:01 +0100
committerMichal Nazarewicz <mina86@mina86.com>2023-01-16 17:56:01 +0100
commit994e712162af1d568a1751c32626478f2c613cc2 (patch)
tree24747f50907ee38bcd669df8bb6b3cd2b70dfd97 /compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
parent506052d49d3903ea554e4ce760cc53610cff4ef5 (diff)
downloadrust-994e712162af1d568a1751c32626478f2c613cc2.tar.gz
rust-994e712162af1d568a1751c32626478f2c613cc2.zip
Implement DoubleEnded and ExactSize for Take<Repeat> and Take<RepeatWith>
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: https://github.com/rust-lang/rust/issues/104434
Issue: https://github.com/rust-lang/rust/issues/104729
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp')
0 files changed, 0 insertions, 0 deletions