nextChunk method
Returns the next n elements of the iterator as an Arr, If there are not enough elements to fill the array then Err is returned containing an iterator over the remaining elements.
Implementation
@override
Result<Arr<T>, RIterator> nextChunk(int size) {
final arr = Arr<T?>(null, size);
for (var i = 0; i < size; i++) {
if (!moveNext()) {
return Err(this);
}
arr[i] = current;
}
return Ok(arr.cast<T>());
}