stellar / rs-soroban-sdk

Rust SDK for Soroban contracts.
Apache License 2.0
118 stars 67 forks source link

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

Open willemneal opened 4 weeks ago

willemneal commented 4 weeks ago

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

https://github.com/stellar/rs-soroban-sdk/blob/d40bd031c14fbd3d75cf4473486ef7ef15af3364/soroban-sdk/src/map.rs#L350-L352

leighmcculloch commented 3 weeks ago

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

leighmcculloch commented 3 weeks ago

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.