Consider a loop
for (i, elt) in zip(indexes, itr)
do_something(i, elt)
end
where Base.IteratorSize(itr)
can potentially be Base.HasLength()
or Base.SizeUnknown()
. I want the code to work for both.
indexes
is an AbstractVector
so I know its length
.
I want to check that the iteration does not terminate “early” because itr
is shorter than `indexes. What’s the idiomatic way to do so?
I thought of the following:
- manually
iterate
itr using, - use a counter and check that.
But neither seems elegant.