-
Notifications
You must be signed in to change notification settings - Fork 327
Description
I have a method that takes a value, creates a new key, inserts those into the map, and returns the key to the caller. I can't find a way to just return a reference to the key since the reference from OccupiedEntry::key can't outlive the current function. In this situation, it seems like I need to either clone the key or return the whole OccupiedEntry.
It seems like I could solve this if OccupiedEntry had an into_key method be that consumes the entry and returns a reference to the key with the lifetime of the original borrow from the hashmap (like OccupiedEntry::into_mut does for the value). Is this a reasonable solution? Is there a reason this can't exist or an existing way to achieve this? I wasn't able to find anything on the topic from searching existing issues.