This happens because there’s no way in current Swift (5.2) to specify the associated type for an opaque return value. Thus,
some IteratorProtocol is not enough for the compiler to figure out what kind of values should the
next() method return.
This limitation of the language forces you to explicitly declare the iterator type if you want to actually use the sequence.
CLICK HERE to find out more related problems solutions.