3 ms·
Have a link to your code? > HashMap<T: Hash+Eq, u64> I can take a wild guess that T is a generic type defined on either the method, struct or impl in which th
by bluejekyll 10y ago
Have a link to your code?
> HashMap<T: Hash+Eq, u64>
I can take a wild guess that T is a generic type defined on either the method, struct or impl in which this HashMap is declared. It's on the method/struct/impl. You don't necessarily need the type bound on the struct, but you do on the impl declaration:
struct MyStruct<T: Hash+Eq> {
map: HashMap<T, u64>
}
impl<T: Hash+Eq> MyStruct<T> {
pub fn insert_something(&mut self, my_key: T, my_int: u64) {
self.map.insert(my_key, my_int);
}
}
try it here: https://is.gd/RwUpQx https://is.gd/RwUpQx