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

feat: add OccupiedEntry.get_entry_mut, VacantEntry.insert_entry #118

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jhgg
Copy link

@jhgg jhgg commented Mar 27, 2020

Adds 2 utility functions ontop of the Entry API.

  • OccupiedEntry.get_entry_mut - for when you want a reference to the key, and a mutable reference to the value.
  • VacantEntry.insert_entry - for when you want to insert into the map, and return a reference to the key, and a mutable reference to the value.

@cuviper
Copy link
Member

cuviper commented Mar 27, 2020

Has anything like this been proposed for the std maps? Ideally, we would keep a compatible API, and these methods don't seem particular to IndexMap.

@jhgg
Copy link
Author

jhgg commented Mar 27, 2020

No :( I just needed these for a project I'm working on - and felt like it'd be cool to upstream it here. I don't have the time to get these into std tho.

@glaebhoerl
Copy link

A similar API was recently added to hashbrown: rust-lang/hashbrown#145

@cuviper cuviper added the waiting-for-std Changes waiting for stabilization in the standard library, so we can match the API. label Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-for-std Changes waiting for stabilization in the standard library, so we can match the API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants