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: Rust Playground

Thank you.

1 Like

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

https://github.com/rust-lang/rust/pull/54043

https://github.com/rust-lang/rust/issues/56167

2 Likes

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.