Tracking issue for Vec::extract_if and LinkedList::extract_if #43244
Open
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: Allocator> Vec<T, A> {
pub fn extract_if<F>(&mut self, filter: F) -> ExtractIf<'_, T, F, A>
where
F: FnMut(&mut T) -> bool,
{
}
}
#[derive(Debug)]
pub struct ExtractIf<'a, T, F, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global>
where
F: FnMut(&mut T) -> bool, {}
impl<T, F, A: Allocator> Iterator for ExtractIf<'_, T, F, A>
where
F: FnMut(&mut T) -> bool,
{
type Item = T;
fn next(&mut self) -> Option<T> {}
fn size_hint(&self) -> (usize, Option<usize>) {}
}
impl<T, F, A: Allocator> Drop for ExtractIf<'_, T, F, A>
where
F: FnMut(&mut T) -> bool,
{
fn drop(&mut self) {}
}
}
pub mod collections {
pub mod linked_list {
impl<T> LinkedList<T> {
pub fn extract_if<F>(&mut self, filter: F) -> ExtractIf<'_, T, F>
where
F: FnMut(&mut T) -> bool,
{
}
}
pub struct ExtractIf<'a, T: 'a, F: 'a>
where
F: FnMut(&mut T) -> bool, {}
impl<T, F> Iterator for ExtractIf<'_, T, F>
where
F: FnMut(&mut T) -> bool,
{
type Item = T;
fn next(&mut self) -> Option<T> {}
fn size_hint(&self) -> (usize, Option<usize>) {}
}
impl<T, F> Drop for ExtractIf<'_, T, F>
where
F: FnMut(&mut T) -> bool,
{
fn drop(&mut self) {}
}
impl<T: fmt::Debug, F> fmt::Debug for ExtractIf<'_, T, F>
where
F: FnMut(&mut T) -> bool,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {}
}
}
}
}
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.
Metadata
Assignees
Labels
Area: `std::collection`Blocker: Implemented in the nightly compiler and unstable.Category: An issue tracking the progress of sth. like the implementation of an RFCLibs issues that are tracked on the team's project board.Relevant to the library API team, which will review and decide on the PR/issue.This issue / PR is in PFCP or FCP with a disposition to merge it.The final comment period is finished for this PR / Issue.