8

Implement VecDeque::retain_mut by GuillaumeGomez · Pull Request #91215 · rust-la...

 2 years ago
source link: https://github.com/rust-lang/rust/pull/91215
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Conversation

Part of #90829.

In #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

This comment has been hidden.

Copy link

Contributor

the8472 commented 16 days ago

If we add a new variant of retain it would be nice to add a range parameter, it helps in cases where one only wants to work on a sub-section of an vec, e.g. when a callee appended N items then it can be more efficient to only post-filter those items but not the whole vec.

Copy link

Member

Author

GuillaumeGomez commented 16 days ago

It seems like a completely different feature. You can't have more parameter in retain_mut than in retain. Maybe a retain_range or something along the line?

Copy link

Contributor

the8472 commented 16 days ago

Sure, the name could be different, but imo not having the range on retain was simply an oversight since one always could have done retain(.., |foo| {/* condition */}), so any new method should have it.

In this case &mut is a more powerful version because a &mut self is taken of the vec anyway, so if we're making a more powerful version we might as well add the range.

Copy link

Member

Author

GuillaumeGomez commented 16 days ago

Please open an issue so you can talk about it with libs team and not flood this PR too much.

Copy link

Member

m-ou-se commented 7 days ago

@bors r+ rollup

Copy link

Contributor

bors commented 7 days ago

pushpin Commit 0466a12 has been approved by m-ou-se

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Projects

None yet

Milestone

1.59.0

Linked issues

Successfully merging this pull request may close these issues.

None yet

8 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK