Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking for map_entry_recover_keys #34285
Comments
seanmonstar
referenced this issue
Jun 15, 2016
Merged
Map::Entry methods to recover key and value together #33300
alexcrichton
added
T-libs
B-unstable
labels
Jun 15, 2016
This comment has been minimized.
This comment has been minimized.
|
Specifically covers:
for both I would personally still hesitate a little on the name |
sfackler
added
the
I-nominated
label
Jul 11, 2016
alexcrichton
added
final-comment-period
and removed
I-nominated
labels
Jul 13, 2016
This comment has been minimized.
This comment has been minimized.
|
Note though that the libs team isn't entirely comfortable with the name |
This comment has been minimized.
This comment has been minimized.
|
I somewhat like |
This comment has been minimized.
This comment has been minimized.
|
Sounds like a great fit to me! |
This comment has been minimized.
This comment has been minimized.
|
Is there any way to recover the key used in the entry from an occupied entry? That is, I'm trying to write a multimap like with the following insert definition: let mut key = (key, 0);
loop {
match self.values.entry(key) {
Entry::Vacant(e) => {
let idx = e.key().1;
e.insert(value);
return idx;
},
Entry::Occupied(e) => {
key = e.??? /* What here? */
key.1 += 1;
}
}
}I don't want to remove the key/value pair from the hash-map, I just want my key back! |
This comment has been minimized.
This comment has been minimized.
|
@Stebalien I believe not currently, no, but it is the subject of an RFC or two |
This comment has been minimized.
This comment has been minimized.
|
Got it. I just want to make sure the APIs play well together. Specifically, given that we want a way to to move keys out
impl Into<K> for Entry {}
impl Into<K> for OccupiedEntry {}
impl Into<K> for VacantEntry {}Note: I'm proposing (2) because having two different |
This comment has been minimized.
This comment has been minimized.
|
Hm yeah that's actually a good point about |
This comment has been minimized.
This comment has been minimized.
|
We can't actually write those |
This comment has been minimized.
This comment has been minimized.
|
The libs team discussed this recently and concluded:
As a result our conclusions were:
|
seanmonstar commentedJun 15, 2016
No description provided.