I have a number of Rust iterators specified by user input that I would like to iterate through in lockstep.
This sounds like a job for something like Iterator::zip
, except that I may need more than two iterators zipped together. I looked at itertools::multizip
and itertools::izip
, but those both require that the number of iterators to be zipped be known at compile time. For my task the number of iterators to be zipped together depends on user input, and thus cannot be known at compile time.
I was hoping for something like Python's zip
function which takes an iterable of iterables. I imagine the function signature might look like:
fn manyzip<T>(iterators: Vec<T>) -> ManyZip<T>
where
T: Iterator
How can I zip more than two iterators? only answers for the situation where the number of iterators is known at compile time.
I can solve my particular problem using indices and such, it just feels like there ought to be a better way.