Skip to content

Tracking issue for Vec::extract_if and LinkedList::extract_if #43244

Closed
@Gankra

Description

@Gankra

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

Unresolved Questions

  • What should the method be named?
  • Should extract_if accept a Range argument?
  • Missing Send+Sync impls on linked list's ExtractIf, see comment

See #43244 (comment) for a more detailed summary of open issues.

Metadata

Metadata

Assignees

Labels

A-collectionsArea: `std::collections`B-unstableBlocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCLibs-TrackedLibs 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.disposition-mergeThis 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.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions