You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This feature adds the Vec::pop_if method, which takes a predicate, evaluates it with the last element in the Vec if present, and returns the item if the predicate returns true. This makes it possible to conditionally remove the last element without the use of unwrap.
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!
See this document for info about what commands tagged team members can give me.
@rfcbot concern impl-trait-syntax (well, I guess not enough rights)
Is there a reason why we use f: F ... where F: Fn... syntax instead of just f: impl Fn...? I recall having (or reading) a discussion about this with a reviewer like a year ago, and IIRC, they said that impl Fn is generally preferred, but since this syntax wasn't there since Rust 1.0, some APIs got stuck with an explicit generic argument.
Activity
Rollup merge of rust-lang#123107 - avandesa:vec_pop_if, r=joboet
Unrolled build for rust-lang#123107
GrigorenkoPV commentedon Jan 14, 2025
Found a piece of code in the wild that could benefit (get rid of an
.unwrap()) with this API stabilized:https://github.com/XAMPPRocky/tokei/blob/edbd5d5cbb0b7ea0081df0265a8ae6e7742a5051/src/language/syntax.rs#L663-L668
Also I myself have found this feature to be useful on couple occasions in personal projects.
This does not look too controversial, so maybe let's stabilize it?
The corresponding
VecDequemethods can be added and stabilized later without blocking this.I don't think I have right to start an FCP, so I will just open a PR instead.
tgross35 commentedon Jan 16, 2025
Docs should probably mention that the function does not get run if the vector is empty.
You can add the I-libs-api-nominated label with rustbot
GrigorenkoPV commentedon Jan 17, 2025
Thanks, that makes sense
@rustbot label +I-libs-api-nominated
True, it might have side-effects, so it's probably worth mentioning. I will adjust my PR.
Amanieu commentedon Jan 21, 2025
@rfcbot merge
rfcbot commentedon Jan 21, 2025
Team member @Amanieu has proposed to merge this. The next step is review by the rest of the tagged team members:
No concerns currently listed.
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!
See this document for info about what commands tagged team members can give me.
GrigorenkoPV commentedon Jan 22, 2025
@rfcbot concern impl-trait-syntax(well, I guess not enough rights)Is there a reason why we use
f: F ... where F: Fn...syntax instead of justf: impl Fn...? I recall having (or reading) a discussion about this with a reviewer like a year ago, and IIRC, they said thatimpl Fnis generally preferred, but since this syntax wasn't there since Rust 1.0, some APIs got stuck with an explicit generic argument.Should I change this from
to
in stabilization PR (#135488)?
Amanieu commentedon Jan 22, 2025
Yes, please do. It's always backwards-compatible to change an
impl Traitto a generic parameter, but not the other way around.2 remaining items
rfcbot commentedon Jan 29, 2025
🔔 This is now entering its final comment period, as per the review above. 🔔
rfcbot commentedon Feb 8, 2025
The final comment period, with a disposition to merge, as per the review above, is now complete.
As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.
This will be merged soon.
Rollup merge of rust-lang#135488 - GrigorenkoPV:vec_pop_if, r=jhpratt
Rollup merge of rust-lang#135488 - GrigorenkoPV:vec_pop_if, r=jhpratt
Unrolled build for rust-lang#135488
Rollup merge of rust-lang#135488 - GrigorenkoPV:vec_pop_if, r=jhpratt
Rollup merge of rust-lang#135488 - GrigorenkoPV:vec_pop_if, r=jhpratt