-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Iterator::map_windows
#94667
Add Iterator::map_windows
#94667
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @m-ou-se (or someone else) soon. Please see the contribution instructions for more information. |
This comment has been minimized.
This comment has been minimized.
b9a1991
to
a656b7b
Compare
This comment has been minimized.
This comment has been minimized.
455690c
to
32bab75
Compare
32bab75
to
156ed5a
Compare
r? @rust-lang/libs |
☔ The latest upstream changes (presumably #95798) made this pull request unmergeable. Please resolve the merge conflicts. |
031b77e
to
16f5885
Compare
☔ The latest upstream changes (presumably #91970) made this pull request unmergeable. Please resolve the merge conflicts. |
Going to mark as waiting-on-author since it's in draft and has some conflicts -- not really clear what the state of this PR is though. If you'd like a review, please leave a comment with |
Got busy recently. Actually, I think there should be more tests, while I'm not sure what are the best ways to test it. Maybe a review could help. @rustbot ready |
Reassigning yaahc's reviews as she has stepped down from the review rotation. r? rust-lang/libs-api |
Reassigning BurntSushi's reviews because based on r? rust-lang/libs-api |
The fix for that is adding |
@rustbot ready |
r=me with a rebase @rustbot author |
33baa61
to
aa06718
Compare
Didn't see that message, sorry for the long wait. @rustbot ready. |
Could not assign reviewer from: |
aa06718
to
95bd131
Compare
This is inherited from the old PR. This method returns an iterator over mapped windows of the starting iterator. Adding the more straight-forward `Iterator::windows` is not easily possible right now as the items are stored in the iterator type, meaning the `next` call would return references to `self`. This is not allowed by the current `Iterator` trait design. This might change once GATs have landed. The idea has been brought up by @m-ou-se here: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Iterator.3A.3A.7Bpairwise.2C.20windows.7D/near/224587771 Co-authored-by: Lukas Kalbertodt <lukas.kalbertodt@gmail.com>
95bd131
to
97c953f
Compare
@bors r+ |
…llaumeGomez Rollup of 5 pull requests Successful merges: - rust-lang#94667 (Add `Iterator::map_windows`) - rust-lang#114069 (Allow using external builds of the compiler-rt profile lib) - rust-lang#114354 (coverage: Store BCB counter info externally, not directly in the BCB graph) - rust-lang#114625 (CI: use smaller machines in PR runs) - rust-lang#114777 (Migrate GUI colors test to original CSS color format) r? `@ghost` `@rustbot` modify labels: rollup
Tracking issue: #87155.
This is inherited from the old PR #82413.
Unlike #82413, this PR implements the
MapWindows
to be lazy: only when pulling from the outer iterator,.next()
of the inner iterator will be called.Implementaion Steps
MapWindows
to keep the iterators' Laziness contract.MapWindows
.Iterator::size_hint
,,Iterator::count
ExactSizeIterator
(whenI: ExactSizeIterator
),,TrustedLen
(whenI: TrustedLen
)FusedIterator
,,Iterator::advance_by
,Iterator::nth
Unresolved Questions:
rmap_windows
or something else?FnMut(&[I::Item; N]) -> R
or something likeFnMut(ArrayView<'_, I::Item, N>) -> R
? WhereArrayView
is mentioned in Extendingcore::ops::Index
to return non-references generic-associated-types-initiative#2.LendingIterator::windows
.iter.map_windows(|_arr: [_; N]| ())
, unless we extend the array pattern to allow matching theArrayView
.