Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does Map::try_get not take a reference to the generic key? #1314

Open
willemneal opened this issue Aug 15, 2024 · 2 comments
Open

Why does Map::try_get not take a reference to the generic key? #1314

willemneal opened this issue Aug 15, 2024 · 2 comments

Comments

@willemneal
Copy link
Member

Since into_val takes a reference to self, why does this method not use &K?

pub fn try_get(&self, k: K) -> Result<Option<V>, V::Error> {
let env = self.env();
let k = k.into_val(env);

@willemneal willemneal changed the title Why is Map::try_get Why is Map::try_get not take a reference to the generic key? Aug 15, 2024
@willemneal willemneal changed the title Why is Map::try_get not take a reference to the generic key? Why does Map::try_get not take a reference to the generic key? Aug 15, 2024
@leighmcculloch
Copy link
Member

It should probably be using the Borrow type instead, similar to:

@leighmcculloch
Copy link
Member

We could make the change to Borrow, but it'll technically be a breaking change, although for most people it won't because the original value should continue to work. If the change can be contributed before v22 release it could probably get in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@leighmcculloch @willemneal and others