Closed
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))