Avoid unnecessary key.clone() when accessing HashMap.entry()

Is it possible to access HashMap::entry() without cloning the key for every access? I know this is necessary for insertions but entry() forces you to always move the key just in case. This is a problem when using complex (immutable) values as key.

Here's a stripped down usage example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=01d58c7e0e199e3a9d39e3db322fb1a4

Thank you.

1 Like

The new raw api would allow this, but the current api does not have a good way to solve this.


Thanks a lot for the info!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.