How to add constraints on generics
问题 I'm having trouble finding out how I constrain the generic types. It seem like K need to implement the core::cmp::Eq and core::hash::Hash traits. I've been unable to find the required syntax in the docs. use std::collections::HashMap; struct Foo<K, V> { map: HashMap<K, V>, } impl<K, V> Foo<K, V> { fn insert_something(&mut self, k: K, v: V) { self.map.insert(k, v); } } The compiler errors are: error[E0599]: no method named `insert` found for struct `std::collections::HashMap<K, V>` in the