I am trying to write a generic code over a collections::hash_map::HashMap
.
While trying to follow the API of get which is:
pub fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V>
where
K: Borrow<Q>,
Q: Hash + Eq,
my own get
has the same signature. How do I reuse this k
of type &Q
when accessing the internal HashMap
? For example, insert expect a real K
, but all I have at hand is &Q
.
pub fn insert(&mut self, k: K, v: V) -> Option<V>