Rewinding iterators in general is impossible. For example, consider:
proc = open(`sh -c 'while true; do echo $RANDOM; done'`)
iter = eachline(proc)
For stateless iterators, you can use IterTools.peekiter. It should be possible to implement this for stateful iterators (or iterators that perform expensive some computation) by buffering peeked elements.
you are basically recreating your itr, what (from an efficiency perspective) matters is the relation between the data (i.e itr and its elements), can you maybe construct a use case for this and see what’s the best options are?