rust/library
bors f24a6ba06f Auto merge of #106943 - mina86:exact_size_take_repeat, r=dtolnay
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

- [ ] ACP: https://github.com/rust-lang/libs-team/issues/120 (this is actually ACP for repeat_n but this is nearly the same functionality so hijacking it so both approaches can be discussed in one place)
2024-08-17 01:46:24 +00:00
..
alloc Rollup merge of #128759 - notriddle:notriddle/spec-to-string, r=workingjubilee,compiler-errors 2024-08-14 05:05:51 +02:00
backtrace@72265bea21 Update backtrace to 0.3.73 2024-06-06 22:50:45 -07:00
core Auto merge of #106943 - mina86:exact_size_take_repeat, r=dtolnay 2024-08-17 01:46:24 +00:00
panic_abort step cfg(bootstrap) 2024-07-28 14:46:29 -04:00
panic_unwind Auto merge of #128083 - Mark-Simulacrum:bump-bootstrap, r=albertlarsan68 2024-07-30 17:49:08 +00:00
portable-simd Fix doc nits 2024-07-26 13:26:33 +01:00
proc_macro Rollup merge of #128307 - ojeda:unescaped_backticks, r=GuillaumeGomez 2024-07-29 11:42:35 +02:00
profiler_builtins Update cc crate to v1.0.97 2024-05-08 15:06:35 +00:00
rtstartup Let InstCombine remove Clone shims inside Clone shims 2024-07-25 15:14:42 -04:00
rustc-std-workspace-alloc
rustc-std-workspace-core
rustc-std-workspace-std
std Stabilize std:🧵:Builder::spawn_unchecked 2024-08-16 10:43:47 -07:00
stdarch@47b929ddc5 Update stdarch 2024-08-04 03:40:21 +05:30
sysroot Auto merge of #125016 - nicholasbishop:bishop-cb-112, r=tgross35 2024-07-29 07:41:33 +00:00
test Reduce merged doctest source code size 2024-08-13 20:14:56 +02:00
unwind Auto merge of #128083 - Mark-Simulacrum:bump-bootstrap, r=albertlarsan68 2024-07-30 17:49:08 +00:00
windows_targets Add windows-targets crate to std's sysroot 2024-08-09 10:43:43 +00:00
Cargo.lock Rollup merge of #128873 - ChrisDenton:windows-targets, r=Mark-Simulacrum 2024-08-14 05:05:51 +02:00
Cargo.toml Exclude windows-targets from the workspace 2024-08-09 11:06:39 +00:00