indexmap
indexmap copied to clipboard
feat: add OccupiedEntry.get_entry_mut, VacantEntry.insert_entry
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.
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
.
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.
A similar API was recently added to hashbrown: https://github.com/rust-lang/hashbrown/pull/145