-
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
Proposal to add Peekable::peek_mut #77491
Conversation
r? @kennytm (rust_highfive has picked a reviewer for you, use r? to override) |
What's the use case for adding this? |
I've a iterator of |
+1, I've been wanting to add this 🙂 |
@lukaslueg can you open an issue regarding this? once that's done update |
@rust-lang/libs would like your thoughts on this proposal so we can move forward with this |
+1, I am on board with this. |
Expanded docs, similar to |
I'd add |
☔ The latest upstream changes (presumably #79319) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:
|
Rebased due to #77697. Note that I went light on adding new tests for |
Looks like nobody is against adding this (as unstable). :) @bors r+ rollup |
📌 Commit 3b01562 has been approved by |
☀️ Test successful - checks-actions |
…JohnTitor Stabilize `peekable_peek_mut` Resolves rust-lang#78302. Also adds some documentation on `std::iter::Iterator::peekable()` regarding the new method. The feature was added in rust-lang#77491 in Nov' 20, which is recently, but the feature seems reasonably small. Never did a stabilization-pr, excuse my ignorance if there is a protocol I'm not aware of.
Stabilize `peekable_peek_mut` Resolves rust-lang#78302. Also adds some documentation on `std::iter::Iterator::peekable()` regarding the new method. The feature was added in rust-lang#77491 in Nov' 20, which is recently, but the feature seems reasonably small. Never did a stabilization-pr, excuse my ignorance if there is a protocol I'm not aware of.
Stabilize `peekable_peek_mut` Resolves rust-lang#78302. Also adds some documentation on `std::iter::Iterator::peekable()` regarding the new method. The feature was added in rust-lang#77491 in Nov' 20, which is recently, but the feature seems reasonably small. Never did a stabilization-pr, excuse my ignorance if there is a protocol I'm not aware of.
A "peekable" iterator has a
peek()
-method which provides an immutable reference to the next item. We currently do not have a method to modify that item, which we could easily add via apeek_mut()
. See the test for a use-case (alike to my original use case), where a "pristine" iterator is passed on after modifying its state viapeek_mut()
.If there is interest in this, I can expand on the tests and docs.