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

Add Vec::retain_mut #90772

Merged
merged 1 commit into from
Nov 17, 2021
Merged

Add Vec::retain_mut #90772

merged 1 commit into from
Nov 17, 2021

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Nov 10, 2021

This is to continue the discussion started in #83218.

Original comment was:

Take 2 of #34265, since I needed this today.

The reason I think why we should add retain_mut is for coherency and for discoverability. For example we have chunks and chunks_mut or get and get_mut or iter and iter_mut, etc. When looking for mutable retain, I would expect retain_mut to exist. It took me a while to find out about drain_filter. So even if it provides an API close to drain_filter, just for the discoverability, I think it's worth it.

cc @m-ou-se @jonas-schievink @Mark-Simulacrum

@GuillaumeGomez GuillaumeGomez added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Nov 10, 2021
@rust-highfive
Copy link
Collaborator

r? @joshtriplett

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 10, 2021
@rust-log-analyzer

This comment has been minimized.

@m-ou-se
Copy link
Member

m-ou-se commented Nov 12, 2021

The reason I think why we should add retain_mut is for coherency and for discoverability. For example we have chunks and chunks_mut or get and get_mut or iter and iter_mut, etc. When looking for mutable retain, I would expect retain_mut to exist. It took me a while to find out about drain_filter. So even if it provides an API close to drain_filter, just for the discoverability, I think it's worth it.

That sounds very reasonable to me. Feel free to open a tracking issue for it.

@GuillaumeGomez
Copy link
Member Author

Opened the tracking issue (#90829) and updated the PR.

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member Author

CI is happy too. :)

@joshtriplett
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Nov 16, 2021

📌 Commit c15b55a has been approved by joshtriplett

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 16, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 16, 2021
…shtriplett

Add Vec::retain_mut

This is to continue the discussion started in rust-lang#83218.

Original comment was:

> Take 2 of rust-lang#34265, since I needed this today.

The reason I think why we should add `retain_mut` is for coherency and for discoverability. For example we have `chunks` and `chunks_mut` or `get` and `get_mut` or `iter` and `iter_mut`, etc. When looking for mutable `retain`, I would expect `retain_mut` to exist. It took me a while to find out about `drain_filter`. So even if it provides an API close to `drain_filter`, just for the discoverability, I think it's worth it.

cc `@m-ou-se` `@jonas-schievink` `@Mark-Simulacrum`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 16, 2021
…shtriplett

Add Vec::retain_mut

This is to continue the discussion started in rust-lang#83218.

Original comment was:

> Take 2 of rust-lang#34265, since I needed this today.

The reason I think why we should add `retain_mut` is for coherency and for discoverability. For example we have `chunks` and `chunks_mut` or `get` and `get_mut` or `iter` and `iter_mut`, etc. When looking for mutable `retain`, I would expect `retain_mut` to exist. It took me a while to find out about `drain_filter`. So even if it provides an API close to `drain_filter`, just for the discoverability, I think it's worth it.

cc ``@m-ou-se`` ``@jonas-schievink`` ``@Mark-Simulacrum``
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 16, 2021
…shtriplett

Add Vec::retain_mut

This is to continue the discussion started in rust-lang#83218.

Original comment was:

> Take 2 of rust-lang#34265, since I needed this today.

The reason I think why we should add `retain_mut` is for coherency and for discoverability. For example we have `chunks` and `chunks_mut` or `get` and `get_mut` or `iter` and `iter_mut`, etc. When looking for mutable `retain`, I would expect `retain_mut` to exist. It took me a while to find out about `drain_filter`. So even if it provides an API close to `drain_filter`, just for the discoverability, I think it's worth it.

cc ```@m-ou-se``` ```@jonas-schievink``` ```@Mark-Simulacrum```
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 16, 2021
…shtriplett

Add Vec::retain_mut

This is to continue the discussion started in rust-lang#83218.

Original comment was:

> Take 2 of rust-lang#34265, since I needed this today.

The reason I think why we should add `retain_mut` is for coherency and for discoverability. For example we have `chunks` and `chunks_mut` or `get` and `get_mut` or `iter` and `iter_mut`, etc. When looking for mutable `retain`, I would expect `retain_mut` to exist. It took me a while to find out about `drain_filter`. So even if it provides an API close to `drain_filter`, just for the discoverability, I think it's worth it.

cc ````@m-ou-se```` ````@jonas-schievink```` ````@Mark-Simulacrum````
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 17, 2021
…shtriplett

Add Vec::retain_mut

This is to continue the discussion started in rust-lang#83218.

Original comment was:

> Take 2 of rust-lang#34265, since I needed this today.

The reason I think why we should add `retain_mut` is for coherency and for discoverability. For example we have `chunks` and `chunks_mut` or `get` and `get_mut` or `iter` and `iter_mut`, etc. When looking for mutable `retain`, I would expect `retain_mut` to exist. It took me a while to find out about `drain_filter`. So even if it provides an API close to `drain_filter`, just for the discoverability, I think it's worth it.

cc `````@m-ou-se````` `````@jonas-schievink````` `````@Mark-Simulacrum`````
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 17, 2021
…askrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#89610 (warn on must_use use on async fn's)
 - rust-lang#90667 (Improve diagnostics when a static lifetime is expected)
 - rust-lang#90687 (Permit const panics in stable const contexts in stdlib)
 - rust-lang#90772 (Add Vec::retain_mut)
 - rust-lang#90861 (Print escaped string if char literal has multiple characters, but only one printable character)
 - rust-lang#90884 (Fix span for non-satisfied trivial trait bounds)
 - rust-lang#90900 (Remove workaround for the forward progress handling in LLVM)
 - rust-lang#90901 (Improve ManuallyDrop suggestion)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 904dba5 into rust-lang:master Nov 17, 2021
@rustbot rustbot added this to the 1.58.0 milestone Nov 17, 2021
@GuillaumeGomez GuillaumeGomez deleted the vec-retain-mut branch November 17, 2021 20:21
@upsuper
Copy link
Contributor

upsuper commented Nov 25, 2021

Eventually my retain_mut crate can go deprecated 🎉

Also do you have a plan to add this to VecDeque as well?

@GuillaumeGomez
Copy link
Member Author

I can as well. I didn't pay attention to the fact that it wasn't only Vec with this issue...

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 4, 2021
…, r=m-ou-se

Implement VecDeque::retain_mut

Part of rust-lang#90829.

In rust-lang#90772, someone suggested that `retain_mut` should also be implemented on `VecDeque`. I think that it follows the same logic (coherency). So first: is it ok? Second: should I create a new feature for it or can we put it into the same one?

r? `@joshtriplett`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants