-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-collectionsArea: `std::collections`Area: `std::collections`B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.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 RFCLibs-TrackedLibs issues that are tracked on the team's project board.Libs issues that are tracked on the team's project board.T-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(extract_if)]
(previously drain_filter
)
This is a tracking issue for Vec::extract_if
and LinkedList::extract_if
, which can be used for random deletes using iterators.
Public API
pub mod alloc {
pub mod vec {
impl<T, A> Vec<T, A>
where
A: Allocator,
{
pub fn extract_if<F>(&mut self, filter: F) -> ExtractIf<'_, T, F, A>
where
F: FnMut(&mut T) -> bool;
}
pub struct ExtractIf<'a, T, F, #[unstable(feature = "allocator_api", issue = "32838")] A = Global>
where
F: FnMut(&mut T) -> bool,
A: Allocator;
impl<T, F, A> Iterator for ExtractIf<'_, T, F, A>
where
F: FnMut(&mut T) -> bool,
A: Allocator;
impl<T, F, A> Drop for ExtractIf<'_, T, F, A>
where
A: Allocator;
impl<T, F, A> Debug for ExtractIf<'_, T, F, A>
where
T: Debug,
F: Debug,
A: Debug + Allocator;
}
pub mod collections {
pub mod linked_list {
impl<T, A> LinkedList<T, A>
where
A: Allocator,
{
pub fn extract_if<F>(&mut self, filter: F) -> ExtractIf<'_, T, F, A>
where
F: FnMut(&mut T) -> bool;
}
pub struct ExtractIf<'a, T, F, #[unstable(feature = "allocator_api", issue = "32838")] A = Global>
where
T: 'a,
F: 'a + FnMut(&mut T) -> bool,
A: Allocator;
impl<T, F, A> Iterator for ExtractIf<'_, T, F, A>
where
F: FnMut(&mut T) -> bool,
A: Allocator;
impl<T, F> Debug for ExtractIf<'_, T, F, Global>
where
T: Debug;
}
}
}
Steps / History
- Implementation: Add Vec::drain_filter #43245
- removed drain-on-drop behavior, renamed to extract_if
- Stabilization PR
Unresolved Questions
- What should the method be named?
- Should
extract_if
accept aRange
argument? - Missing
Send
+Sync
impls on linked list's ExtractIf, see comment
See #43244 (comment) for a more detailed summary of open issues.
kornelski, real-felix, Xaeroxe, Kvikal, hcpl and 135 moreGrayJack, BlinkyStitt, willcassella, mtnakayama, Kobzol and 22 more
Metadata
Metadata
Assignees
Labels
A-collectionsArea: `std::collections`Area: `std::collections`B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.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 RFCLibs-TrackedLibs issues that are tracked on the team's project board.Libs issues that are tracked on the team's project board.T-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.