I have a hash map of type Map<K, V>
with an entry(k)
function whose signature is:
pub fn entry<Q: Eq + Hash + ?Sized>(&self, key: &Q)
where
K: Borrow<Q> + for<'c> From<&'c Q>,
Using reference types helps avoid unnecessary clones by only calling K::from(key)
when needed. However, this approach doesn't support value types like u32
. Is there a way to make it work with both value types and reference types?