-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the RFC.Relevant to the library API team, which will review and decide on the RFC.
Description
In some cases, I only have one key, and by calling
let e = my_hash_map.entry(k);
I'm giving up my one and only instance of k.
Now I need to use k to populate the entry (imagine my_hash_map memoizes the function my_fun):
e.or_insert_with(|| my_fun(&k))
but I'm out of luck because k has been stolen by the call to entry (k has been moved). By adding an extra function to entry, this can be rectified by
e.or_insert_with_key(|kref| my_fun(kref))
siburu
Metadata
Metadata
Assignees
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the RFC.Relevant to the library API team, which will review and decide on the RFC.