Do we prepare to change `type Output` in the standard library to GAT?

A lending iterator's items may borrow from the iterator. Advancing the iterator mutates it. Therefore, you cannot keep an item and also advance the iterator (because that would be trying to take a mutable borrow while an immutable borrow exists), which is what collect() does repeatedly.

Of course, items could be transformed in a way which un-borrows them, e.g. .map(Clone::clone), to solve this problem in specific cases. Ideally the types are arranged so that if you do that, you can .collect(), but I don't know if that will be possible without further language extensions.

3 Likes