Skip to content
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 remark regarding DoubleEndedIterator #72626

Merged
merged 1 commit into from
May 27, 2020

Conversation

phimuemue
Copy link
Contributor

While reviewing rust-itertools/itertools@14293bd#diff-2c16d2ada06ad2fd1fc754679646d471, I realized that a DoubleEndedIterator may yield different elements depending on whether it is traversed forwards or backwards. (Not only the order, but possibly also the yielded values.)

I found this remarkable, but could not find anything in the current docs, so I thought it may be worth mentioning this explicitly.

Unfortunately, I could not test these changes locally (rustdoc complains about unresolved import). Sorry if this causes headache.

If I should change something, please let me know. If it seems too trivial, feel free to just close this PR.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @dtolnay (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 26, 2020
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that code is a helpful demo of this behavior.

@dtolnay
Copy link
Member

dtolnay commented May 26, 2020

@bors r+ rollup

@bors
Copy link
Contributor

bors commented May 26, 2020

📌 Commit b60fe39 has been approved by dtolnay

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 26, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 27, 2020
…olnay

Add remark regarding DoubleEndedIterator

While reviewing rust-itertools/itertools@14293bd#diff-2c16d2ada06ad2fd1fc754679646d471, I realized that a `DoubleEndedIterator` may yield different elements depending on whether it is traversed forwards or backwards. (Not only the *order*, but possibly also the yielded values.)

I found this remarkable, but could not find anything in the current docs, so I thought it may be worth mentioning this explicitly.

Unfortunately, I could not test these changes locally (`rustdoc` complains about `unresolved import`). Sorry if this causes headache.

If I should change something, please let me know. If it seems too trivial, feel free to just close this PR.
bors added a commit to rust-lang-ci/rust that referenced this pull request May 27, 2020
Rollup of 6 pull requests

Successful merges:

 - rust-lang#72348 (Fix confusing error message for comma typo in multiline statement)
 - rust-lang#72533 (Resolve UB in Arc/Weak interaction (2))
 - rust-lang#72548 (Add test for old compiler ICE when using `Borrow`)
 - rust-lang#72606 (Small cell example update)
 - rust-lang#72610 (Remove font-display settings)
 - rust-lang#72626 (Add remark regarding DoubleEndedIterator)

Failed merges:

r? @ghost
@bors bors merged commit e6353aa into rust-lang:master May 27, 2020
@phimuemue phimuemue deleted the doubleendediter_doc branch May 27, 2020 15:21
@ssomers
Copy link
Contributor

ssomers commented Dec 21, 2021

I stumbled upon the comment and found it definitely useful but hard to understand, and I'm no longer a noob. The sentence "The elements yielded by DoubleEndedIterator’s methods may differ from the ones yielded by Iterator’s methods" sounds mysterious, and there's no further explanation other than figuring out the code. And that code is in the documentation of method next_back but also illustrates rfold.

I suggest it should be about how backward iteration differs from forward iteration, and belongs at the trait level. Or that it limits itself to next_back and reminds you that Iterator has a last that you can invoke on any DoubleEndedIterator, but it does something distinctly different from next_back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants