| Age | Commit message (Collapse) | Author | Lines |
|
zackmdavis:missing_sum_and_product_for_128_bit_integers, r=nagisa
add u128/i128 to sum/product implementors
Resolves #43235.
|
|
Resolves #43235.
|
|
`position` could not be implemented because calling `rposition`
on the inner iterator would require more trait bounds.
|
|
|
|
|
|
|
|
|
|
|
|
Replacement: 41439
Deprecation: 42310 for 1.19
Fixes 41477
|
|
|
|
Add `Iterator::for_each`
This works like a `for` loop in functional style, applying a closure to
every item in the `Iterator`. It doesn't allow `break`/`continue` like
a `for` loop, nor any other control flow outside the closure, but it may
be a more legible style for tying up the end of a long iterator chain.
This was tried before in #14911, but nobody made the case for using it
with longer iterators. There was also `Iterator::advance` at that time
which was more capable than `for_each`, but that no longer exists.
The `itertools` crate has `Itertools::foreach` with the same behavior,
but thankfully the names won't collide. The `rayon` crate also has a
`ParallelIterator::for_each` where simple `for` loops aren't possible.
> I really wish we had `for_each` on seq iterators. Having to use a
> dummy operation is annoying. - [@nikomatsakis][1]
[1]: https://github.com/nikomatsakis/rayon/pull/367#issuecomment-308455185
|
|
|
|
Replaced by adding extra imports, adding hidden code (`# ...`), modifying
examples to be runnable (sorry Homura), specifying non-Rust code, and
converting to should_panic, no_run, or compile_fail.
Remaining "```ignore"s received an explanation why they are being ignored.
|
|
Change the for-loop desugar so the `break` does not affect type inference. Fixes #42618
Rewrite the `for` loop desugaring to avoid contaminating the inference results. Under the older desugaring, `for x in vec![] { .. }` would erroneously type-check, even though the type of `vec![]` is unconstrained. (written by @nikomatsakis)
|
|
The benefit of using internal iteration is shown in new benchmarks:
test iter::bench_for_each_chain_fold ... bench: 635,110 ns/iter (+/- 5,135)
test iter::bench_for_each_chain_loop ... bench: 2,249,983 ns/iter (+/- 42,001)
test iter::bench_for_each_chain_ref_fold ... bench: 2,248,061 ns/iter (+/- 51,940)
|
|
This works like a `for` loop in functional style, applying a closure to
every item in the `Iterator`. It doesn't allow `break`/`continue` like
a `for` loop, nor any other control flow outside the closure, but it may
be a more legible style for tying up the end of a long iterator chain.
This was tried before in #14911, but nobody made the case for using it
with longer iterators. There was also `Iterator::advance` at that time
which was more capable than `for_each`, but that no longer exists.
The `itertools` crate has `Itertools::foreach` with the same behavior,
but thankfully the names won't collide. The `rayon` crate also has a
`ParallelIterator::for_each` where simple `for` loops aren't possible.
> I really wish we had `for_each` on seq iterators. Having to use a
> dummy operation is annoying. - [@nikomatsakis][1]
[1]: https://github.com/nikomatsakis/rayon/pull/367#issuecomment-308455185
|
|
Fixes #42618
|
|
(and fix a minor grammar typo below)
|
|
|
|
Change for-loop desugar to not borrow the iterator during the loop
This is enables the use of suspend points inside for-loops in movable generators. This is illegal in the current desugaring as `iter` is borrowed across the body.
|
|
|
|
Only exposed as DeprecatedStepBy (as of PR 41439)
|
|
Changed all the tests except test_range_step to use Iterator::step_by.
|
|
fix links to "module-level documentation"
see https://github.com/rust-lang/rust/issues/42267
|
|
|
|
This makes the size_hint from things like `take` more precise.
|
|
Override size_hint and propagate ExactSizeIterator for iter::StepBy
Generally useful, but also a prerequisite for moving a bunch of unit tests off `Range*::step_by`.
A small non-breaking subset of https://github.com/rust-lang/rust/pull/42110 (which I closed).
Includes two small documentation changes @ivandardi requested on that PR.
r? @alexcrichton
|
|
Rollup of 7 pull requests
- Successful merges: #42169, #42215, #42216, #42224, #42230, #42236, #42241
- Failed merges:
|
|
Give step_trait a distinct tracking issue from step_by
iterator_step_by has decoupled their futures, so the tracking issue should split.
Old issue: https://github.com/rust-lang/rust/issues/27741
New issue: https://github.com/rust-lang/rust/issues/42168
r? @alexcrichton (another follow-up to closed PR https://github.com/rust-lang/rust/pull/42110#issuecomment-303176049)
|
|
Remove `FusedIterator` implementation of `iter::Scan`
Fixes #41964.
This is a breaking change.
|
|
Make RangeInclusive just a two-field struct
Not being an enum improves ergonomics and consistency, especially since NonEmpty variant wasn't prevented from being empty. It can still be iterable without an extra "done" bit by making the range have !(start <= end), which is even possible without changing the Step trait.
Implements merged https://github.com/rust-lang/rfcs/pull/1980; tracking issue https://github.com/rust-lang/rust/issues/28237.
This is definitely a breaking change to anything consuming `RangeInclusive` directly (not as an Iterator) or constructing it without using the sugar. Is there some change that would make sense before this so compilation failures could be compatibly fixed ahead of time?
r? @aturon (as FCP proposer on the RFC)
|
|
iterator_step_by has decoupled their futures, so the tracking issue should split.
|
|
|
|
Generally useful, but also a prerequisite for moving a bunch of unit tests off Range::step_by.
|
|
Fixes https://github.com/rust-lang/rust/issues/42135
Found while fixing run-pass/range_inclusive test failure.
|
|
Not being an enum improves ergonomics, especially since NonEmpty could be Empty. It can still be iterable without an extra "done" bit by making the range have !(start <= end), which is even possible without changing the Step trait.
Implements RFC 1980
|
|
Correct some stability versions
These were found by running tidy on stable versions of rust and finding
features stabilised with the wrong version numbers.
|
|
These were found by running tidy on stable versions of rust and finding
features stabilised with the wrong version numbers.
|
|
Stabilize step_by by adding it to Iterator (issue #27741)
Inspired by itertools' `take()` method. See issue #27741
|
|
|
|
Fixes #41964.
This is a breaking change.
|
|
|
|
|
|
Step::replace_one should put a one, not a zero (Issue #41492)
Turns out all six of the replace_* impls were backwards.
|
|
Fixes #33269
|
|
Turns out all six of these impls are incorrect.
|
|
|
|
Extend the example a little bit to show behaviour better.
|
|
- Prefer simpler constructs instead of going through &mut I's Iterator
implementation.
|
|
|