Open phymo opened 2 years ago
Notice that the generic type parameter of the Iterator::collect method implements the FromIterator trait. This is where all the magic happens -- if you look at the source of Iterator::collect, you'll see that all it does is call FromIterator::from_iter. Since the compiler expects the return value to be of type B, it infers that FromIterator::from_iter refers to the implementation of FromIterator::from_iter on B (as from_iter returns Self).
into_iter
iter
iter_mut
next