Commit Graph

26 Commits

Author SHA1 Message Date
Jonathan Brouwer 77cbf96954 Rollup merge of #150230 - bend-n:trusted_len_spec_for_iter_next_chunk, r=Mark-Simulacrum
spec next chunk for trustedlen

relevant to rust-lang/rust#98326
2026-04-18 19:23:12 +02:00
Josh Stone a66b7810c3 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]: https://github.com/rayon-rs/rayon/blob/ae07384e3e0b238cea89f0c14891f351c65a5cee/src/iter/repeat.rs#L201-L202
2026-04-16 16:49:11 -07:00
bendn 63f813ab2d spec next chunk for trustedlen 2026-04-13 15:08:04 +07:00
Jalil David Salamé Messina d6b280675e feat(core): impl Step for NonZero<u*>
Implement Step for NonZero unsigned integers as discussed in
[libs-team#130][1].

[1]: https://github.com/rust-lang/libs-team/issues/130

`step_nonzero_impls` was adapted from `step_integer_impls` and the tests
were adapted from the step tests.

Signed-off-by: Jalil David Salamé Messina <jalil.salame@gmail.com>
2026-04-03 13:25:13 -03:00
Jonathan Brouwer df5f98513b Rollup merge of #154190 - Jules-Bertholet:nonfused, r=scottmcm
Don't fuse in `MapWindows`

cc https://github.com/rust-lang/rust/issues/87155

Fusing makes the iterator larger, slower, more complicated, and less useful. Users who need fusing behavior can always use `.fuse()`, but there is no way to get non-fusing behavior from the fused version.

@rustbot label A-iterators
2026-03-29 08:59:36 +02:00
Jules Bertholet 0a49163be7 Don't fuse in MapWindows 2026-03-21 18:16:51 -04:00
Mahdi Ali-Raihan 800d9ea8e8 Lifted intersperse and intersperse_with Fused restrictions and updated documentation + tests 2026-03-14 13:57:10 -04:00
Jonathan Brouwer c4384629c0 Rollup merge of #153265 - asder8215:intersperse_changes, r=jhpratt
Clarified doc comments + added tests confirming current behavior for intersperse/intersperse_with

This PR builds on top of rust-lang/rust#152855. I just added clarifying comments to `intersperse`/`intersperse_with` about its guarantees for fused iterators (and how behavior for non-fused iterators are subject to change). I also added in tests for non-fused iterators demonstrating its current behavior; fused iterators are already tested for in existing tests for `intersperse`/`intersperse_with`.
2026-03-03 07:14:12 +01:00
Mahdi Ali-Raihan c8d343e5c8 Added guarantee and non-guarantee comments + tests for intersperse/intersperse_with regarding fused/non-fused iterators 2026-03-02 19:44:15 -05:00
mu001999 ff0f239bb1 Remove redundant self usages 2026-02-25 22:51:53 +08:00
Deadbeef 6147a3fc88 constify Iterator 2026-01-30 15:52:40 +00:00
bendn 68abe69f13 iter::ArrayChunks::into_remainder ought not return option 2025-11-20 15:27:57 +07:00
Matthias Krüger cb3c6edc9b Rollup merge of #147258 - hkBst:panic-last-repeat, r=scottmcm
iter repeat: panic on last

https://github.com/rust-lang/rust/issues/146660#issuecomment-3356842371
2025-10-18 08:08:36 +02:00
Matthias Krüger 817720c9a9 Rollup merge of #138799 - joboet:extend-tuple, r=Mark-Simulacrum
core: simplify `Extend` for tuples

This is an alternative to https://github.com/rust-lang/rust/pull/137400. The current macro is incredibly complicated and introduces subtle bugs like calling the `extend_one` of the individual collections in backwards order. This PR drastically simplifies the macro by removing recursion and moving the specialization out of the macro. It also fixes the ordering issue described above (I've stolen the test of the new behaviour from https://github.com/rust-lang/rust/pull/137400). Additionally, the 1-tuple is now special-cased to allow taking advantage of the well-optimized `Extend` implementations of the individual collection.
2025-10-12 10:13:12 +02:00
Marijn Schouten d52744e9fc iter repeat: panic on last 2025-10-07 16:43:48 +00:00
Marijn Schouten 50398e2e75 iter repeat: add tests for new count and last behavior 2025-09-30 17:56:18 +00:00
Stuart Cook 732802c207 Rollup merge of #143725 - kennytm:peekable_next_if_map, r=jhpratt
core: add Peekable::next_if_map

Implementation for rust-lang/rust#143702
2025-09-04 10:01:51 +10:00
Jeremy Smart 1a33d628df implement Sum and Product for Saturating(u*) 2025-08-28 18:38:53 -04:00
Rémy Rakic 4ef92bec5a fix load-bearing typo 2025-07-19 15:17:04 +00:00
kennytm 2261154549 core: add Peekable::next_if_map 2025-07-10 20:44:59 +08:00
The 8472 61c2c1211f add comments to Zip unsoundness regression test 2025-06-05 01:28:55 +02:00
The 8472 cdeca5cbd3 fix Zip unsoundness (again)
Some history: The Zip TrustedRandomAccess specialization has tried
to emulate the side-effects of the naive implementation for a long time,
including backwards iteration. 82292¹ tried to fix unsoundness (82291¹) in that
side-effect-preservation code, but this introduced some panic-safety
unsoundness (86443¹), but the fix 86452¹ didn't fix it for nested Zip
iterators (137255¹).

Rather than piling yet another fix ontop of this heap of fixes this PR reduces
the number of cases in which side-effects will be preserved; the necessary
API guarantee change was approved in 83791¹ but we haven't made use of that
so far.

¹ see merge commit for linkfied issues.
2025-06-05 01:27:17 +02:00
Jonathan Gruner f121c7c360 added test for Enumerate::next_index on empty iterator 2025-04-19 12:29:47 +02:00
Frank Steffahn af66ece822 Add tests for Extend<(T, U)> for (ExtendT, ExtendU)
ordering of side-effects to `coretest`.
2025-03-21 21:01:37 +01:00
bjorn3 1fcae03369 Rustfmt 2025-02-08 22:12:13 +00:00
bjorn3 b6a3841942 Put all coretests in a separate crate 2025-01-26 10:26:36 +00:00