-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Milestone
Description
Feature gate: #![feature(vec_pop_if)]
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
.
Public API
impl<T> Vec<T> {
pub fn pop_if(&mut self, f: impl FnOnce(&mut T) -> bool) -> Option<T>;
}
Steps / History
- ACP:
pop_if
orEntry
/Peek
-like API forVec
andVecDeque
libs-team#208 - Implementation: Implement
Vec::pop_if
#123107 - Final comment period (FCP)1: Tracking Issue for
Vec::pop_if
#122741 (comment) - Stabilization PR: Stabilize
vec_pop_if
#135488
Unresolved Questions
- Do we want a
VecDeque::pop_front_if
andVecDeque::pop_back_if
API under this as well?- Separate tracking issue: Tracking Issue for
VecDeque::pop_front_if
&VecDeque::pop_back_if
#135889
- Separate tracking issue: Tracking Issue for
Footnotes
jwodder and stepanchegZalathar, jpramosi, dennsva, timlathy, ngtkana and 5 more
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.