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

Tracking issue for std::iter::Peekable::peek_mut #78302

Closed
2 tasks done
lukaslueg opened this issue Oct 23, 2020 · 0 comments · Fixed by #81938
Closed
2 tasks done

Tracking issue for std::iter::Peekable::peek_mut #78302

lukaslueg opened this issue Oct 23, 2020 · 0 comments · Fixed by #81938
Labels
A-iterators Area: Iterators C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. Libs-Tracked Libs issues that are tracked on the team's project board. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@lukaslueg
Copy link
Contributor

lukaslueg commented Oct 23, 2020

Feature name: peekable_peek_mut

History:


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 a peek_mut(). A draft-implementation to add a new peek_mut-method is in #77491

A peek_mut would allow one to peek into the very next item the iterator will return and change it if so desired (essentially a single-shot .map()):

let xs = vec![1, 2, 3];
let mut it = xs.into_iter().peekable();
if let Some(ref mut p) = it.peek_mut() {
    if **p == 1 {
        **p = 5;
    }
}
assert_eq!(it.collect::<Vec<_>>(), vec![5, 2, 3]);
@lukaslueg lukaslueg added the C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. label Oct 23, 2020
@camelid camelid added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Oct 24, 2020
@KodrAus KodrAus added the Libs-Tracked Libs issues that are tracked on the team's project board. label Nov 6, 2020
@m-ou-se m-ou-se changed the title Add std::iter::Peekable::peek_mut Tracking issue for std::iter::Peekable::peek_mut Nov 24, 2020
@KodrAus KodrAus added the A-iterators Area: Iterators label Nov 28, 2020
lukaslueg added a commit to lukaslueg/rust that referenced this issue Feb 21, 2021
Resolves rust-lang#78302

Update peekable.rs

Update library/core/src/iter/traits/iterator.rs

Co-authored-by: Ashley Mannix <kodraus@hey.com>
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Mar 17, 2021
…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.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 8, 2021
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.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 8, 2021
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.
@bors bors closed this as completed in abcbe54 Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-iterators Area: Iterators C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. Libs-Tracked Libs issues that are tracked on the team's project board. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants