I'm looking for a why to convert a regular iterator into one that supports pushing items back into it. E.g.
item = next(my_iterator)
if went_too_far(item):
my_iterator.pushback(item)
break;
This is similar, but not identical to, an iterator that supports peek
; with the latter, the above would look more like this:
if went_too_far(my_iterator.peek()):
break
else:
item = next(my_iterator)