Conversation
This adds methods to get the original `&'a mut HashMap` reference from
`hash_map::{Entry, EntryRef, OccupiedEntry, VacantEntry, VacantEntryRef}`
to help with current borrow-checker limitations in returning lifetimes
from different branches.
```rust
/// Converts the `Entry` into a mutable reference to the underlying map.
pub fn into_map(self) -> &'a mut HashMap<K, V, S, A>;
```
There are already similar `into_table` methods on `hash_table` occupied
and vacant entries, but this also adds that to `hash_table::Entry` for
consistency.
This idea was raised in an [internals thread][1] for the standard
library, but it's not possible there since those entries don't have any
reference to return, especially since they aren't even parameterized by
the `S` hasher at all -- they are wrapping `RustcEntry` here.
[1]: https://internals.rust-lang.org/t/get-mut-map-back-from-entry-api/24003
|
I also considered this for |
|
So, main concern here is the hasher, and the fact that the table doesn't have one. So, if we were to store a pointer to the table in its entries and want to make the map implemented based upon those, we'd have to probably either do But like, it's not a dealbreaker, just something to consider. |
|
Even if |
|
Fair! I guess that bucket indices are part of that API, now, so, it would work pretty well. |
This adds methods to get the original
&'a mut HashMapreference fromhash_map::{Entry, EntryRef, OccupiedEntry, VacantEntry, VacantEntryRef}to help with current borrow-checker limitations in returning lifetimes
from different branches.
There are already similar
into_tablemethods onhash_tableoccupiedand vacant entries, but this also adds that to
hash_table::Entryforconsistency.
This idea was raised in an internals thread for the standard
library, but it's not possible there since those entries don't have any
reference to return, especially since they aren't even parameterized by
the
Shasher at all -- they are wrappingRustcEntryhere.