Files
rust/library/coretests/tests
Jacob Pratt 221dab89b4 Rollup merge of #139690 - cuviper:iter_repeat_n_default, r=tgross35
`impl Default for RepeatN`

This creates an empty iterator, like `repeat_n(value, 0)` but without
needing any such value at hand. There's precedent in many other
iterators that the `Default` is empty, like `slice::Iter`.

I found myself wanting this for rayon's `RepeatN` as it lowers to a
sequential iterator [here][1]. Since rayon is also optimizing to avoid
extra clones, it may end up with parallel splits that have count 0 and
no item value. Calling `std::iter::repeat_n(x, 0)` just drops that
value, but there's no way to construct the same result without a value
yet. This would be straightforward with an empty `Default`.

[1]: ae07384e3e/src/iter/repeat.rs (L201-L202)

r? libs-api (insta-stable)
2026-04-18 00:05:16 -04:00
..
…
…
2026-04-16 16:49:11 -07:00
2026-02-20 10:16:36 +01:00
…
…
2026-01-11 16:39:18 +03:00
…
…
…
2026-01-23 15:12:47 +07:00
…
2026-03-23 08:17:14 -04:00
2025-12-12 06:31:00 +02:00
2026-04-08 17:59:14 +02:00
…
…
…
…
…
2026-02-20 10:16:36 +01:00
…
…
…
…
…
2026-03-25 11:40:27 +07:00
…
…
…
2026-01-29 11:12:54 -08:00
…
…
…
…
…