Function itertools::multizip
[−]
[src]
pub fn multizip<T, U>(t: U) -> Zip<T> where Zip<T>: From<U>, Zip<T>: Iterator
An iterator that generalizes .zip() and allows running multiple iterators in lockstep.
The iterator Zip<(I, J, ..., M)>
is formed from a tuple of iterators (or values that
implement IntoIterator
) and yields elements
until any of the subiterators yields None
.
The iterator element type is a tuple like like (A, B, ..., E)
where A
to E
are the
element types of the subiterator.
use itertools::multizip; // Iterate over three sequences side-by-side let mut xs = [0, 0, 0]; let ys = [69, 107, 101]; for (i, a, b) in multizip((0..100, &mut xs, &ys)) { *a = i ^ *b; } assert_eq!(xs, [69, 106, 103]);