3 ms·
It depends on whether the underlying stream supports "peek". If not, in order to determine whether there is a next element, the iterator must consume the next
by wffurr 8y ago
It depends on whether the underlying stream supports "peek". If not, in order to determine whether there is a next element, the iterator must consume the next element and hold it in local memory until a call to next.
That can matter in certain cases of large objects or slow or side-effecting stream access