Question about Trait Bounds (from Rust for Rustaceans)
In Rust for Rustaceans' section about Trait Bounds on page 31 in the last 5 lines it says:
For example, if your method wants to construct a
HashMap<K, V, S>whose keys are some generic typeTand whose value is ausize, instead of writing the bounds likewhere T: Hash + Eq, S: BuildHasher + Default, you could writewhere HashMap<T, usize, S>: FromIterator.
While I can confirm that where T: Hash + Eq, S: BuildHasher + Default does work. The alternative where HashMap<T, usize, S>: FromIterator does not work for me as you can see here. I don't think the author Jon Gjengset (I love this guy) is wrong as it would have been resolved in the errata.
- How do I apply the
where HashMap<...>clause correctly without using the bounds? - Why is the generic
<T>ofFromIteratormissing?