Open
Description
openedon Jul 14, 2017
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment