2 ms·
In the standard library today, there's no bounds on `K` on the definition of HashMap, only on the impl block containing its methods. This sort of makes HashMap
by tatterdemalion 10y ago
In the standard library today, there's no bounds on `K` on the definition of HashMap, only on the impl block containing its methods. This sort of makes HashMap a bad example for this code block; you're right that if the bounds were on the definition instead of the impl, the argument itself would be invalid.
- robohamburger 10y agoI think it becomes useful only if whatever struct expects some extra level of behavior from the types. Basically any time a struct or a trait is coupled with another trait or needs a particular marker/lifetime to function I find myself repeating the bounds over and over. For example in gfx-rs it might be repeating the gfx::Resources or gfx::Factory trait bounds.