Conversation
|
|
This comment has been minimized.
This comment has been minimized.
9faa93f to
63ad76d
Compare
A PR to update https://github.com/rust-lang/hashbrown may be needed first to make |
|
Okay, I will keep this PR a draft for now. |
This comment has been minimized.
This comment has been minimized.
|
This is a test. It won't compile right now since I was using a local build of hashbrown. Let me know what you think. |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
Originally I was thinking that I guess I'll re-nominate for @rust-lang/libs-api because there's a tradeoff here. Question: is there any interest in something like this as an alternative to putting the key in the pub struct OccupiedEntry<...> {
hash: u64,
elem: Bucket<(K, V)>,
table: &'a mut HashMap<K, V, S, A>,
original_key: Option<K>, // new field
}
impl<...> OccupiedEntry<...> {
fn original_key(&mut self) -> &mut Option<K>;
}The advantage is that users can get the unused owned @rustbot label +I-libs-api-nominated @malezjaa in the meantime feel free to open the HashBrown PR, and please add tests that the key is actually present when expected. |
|
Personally storing the key on It's true that |
Made changes according to #82766 (comment).
The only thing I wasn't sure about was adding Clone bound to key, even though I think this is the only way to do that, because .entry() consumes the key.
r? @tgross35