Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking Issue for linked_list_retain #114135

Open
1 of 3 tasks
TennyZhuang opened this issue Jul 27, 2023 · 3 comments
Open
1 of 3 tasks

Tracking Issue for linked_list_retain #114135

TennyZhuang opened this issue Jul 27, 2023 · 3 comments
Assignees
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@TennyZhuang
Copy link
Contributor

TennyZhuang commented Jul 27, 2023

Feature gate: #![feature(linked_list_retain)]

This is a tracking issue for LinkedList::{retain, retain_mut}

Public API

// alloc::collections

pub struct LinkedList;

impl LinkedList {
    pub fn retain_mut<F>(&mut self, mut f: F)
    where
        F: FnMut(&mut T) -> bool;

    pub fn retain<F>(&mut self, mut f: F)
    where
        F: FnMut(&T) -> bool;
}

Steps / History

Unresolved Questions

  • None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

@TennyZhuang TennyZhuang added C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Jul 27, 2023
@TennyZhuang
Copy link
Contributor Author

@rustbot claim

@finnbear
Copy link
Contributor

finnbear commented Aug 7, 2023

As far as I know, {Vec, VecDeque}::retain(&mut self, fn(&T) -> bool) use an immutable reference for backwards compatibility, and retain_mut was a workaround. See #90829 and #39560 (comment) (there are no {Hash, BTree}Map::retain_mut and {Hash, BTree}Map::retain provide mutable references).

Are you adding LinkedList::{retain, retain_mut} for consistency/code clarity or could they be merged into retain with mutable references?

@TennyZhuang
Copy link
Contributor Author

As far as I know, {Vec, VecDeque}::retain(&mut self, fn(&T) -> bool) use an immutable reference for backwards compatibility, and retain_mut was a workaround

Sorry, I just found out about this.

could they be merged into retain with mutable references?

If consistency between collections has already been broken by {Hash, BTree}Map, I can just merge them to a single retain.

bors added a commit to rust-lang-ci/rust that referenced this issue Nov 24, 2023
…omcc

add LinkedList::{retain,retain_mut}

Implement rust-lang#114135

The API is consistent with other collections.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Dec 8, 2023
…thomcc

add LinkedList::{retain,retain_mut}

Implement rust-lang#114135

The API is consistent with other collections.
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 9, 2023
…omcc

add LinkedList::{retain,retain_mut}

Implement rust-lang#114135

The API is consistent with other collections.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants