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?
pub fn entry<Q>(&self, key: &Q)
where
Q: Eq + Hash + ?Sized + ToOwned<Owned = K>,
// Technically implied by the above but you need this to avoid
// breaking inference
K: Borrow<Q>,
Yeah, I have tried this approach, but it does not solve all my problems. For example, my key type is CustomBytes, and the parameter type passed in is &[u8].