[][src]Function itertools::multizip

pub fn multizip<T, U>(t: U) -> Zip<T>

Notable traits for Zip<(A,)>

impl<A> Iterator for Zip<(A,)> where
    A: Iterator
type Item = (A::Item,);impl<A, B> Iterator for Zip<(A, B)> where
    A: Iterator,
    B: Iterator
type Item = (A::Item, B::Item);impl<A, B, C> Iterator for Zip<(A, B, C)> where
    A: Iterator,
    B: Iterator,
    C: Iterator
type Item = (A::Item, B::Item, C::Item);impl<A, B, C, D> Iterator for Zip<(A, B, C, D)> where
    A: Iterator,
    B: Iterator,
    C: Iterator,
    D: Iterator
type Item = (A::Item, B::Item, C::Item, D::Item);impl<A, B, C, D, E> Iterator for Zip<(A, B, C, D, E)> where
    A: Iterator,
    B: Iterator,
    C: Iterator,
    D: Iterator,
    E: Iterator
type Item = (A::Item, B::Item, C::Item, D::Item, E::Item);impl<A, B, C, D, E, F> Iterator for Zip<(A, B, C, D, E, F)> where
    A: Iterator,
    B: Iterator,
    C: Iterator,
    D: Iterator,
    E: Iterator,
    F: Iterator
type Item = (A::Item, B::Item, C::Item, D::Item, E::Item, F::Item);impl<A, B, C, D, E, F, G> Iterator for Zip<(A, B, C, D, E, F, G)> where
    A: Iterator,
    B: Iterator,
    C: Iterator,
    D: Iterator,
    E: Iterator,
    F: Iterator,
    G: Iterator
type Item = (A::Item, B::Item, C::Item, D::Item, E::Item, F::Item, G::Item);impl<A, B, C, D, E, F, G, H> Iterator for Zip<(A, B, C, D, E, F, G, H)> where
    A: Iterator,
    B: Iterator,
    C: Iterator,
    D: Iterator,
    E: Iterator,
    F: Iterator,
    G: Iterator,
    H: Iterator
type Item = (A::Item, B::Item, C::Item, D::Item, E::Item, F::Item, G::Item, H::Item);impl<A, B, C, D, E, F, G, H, I> Iterator for Zip<(A, B, C, D, E, F, G, H, I)> where
    A: Iterator,
    B: Iterator,
    C: Iterator,
    D: Iterator,
    E: Iterator,
    F: Iterator,
    G: Iterator,
    H: Iterator,
    I: Iterator
type Item = (A::Item, B::Item, C::Item, D::Item, E::Item, F::Item, G::Item, H::Item, I::Item);impl<A, B, C, D, E, F, G, H, I, J> Iterator for Zip<(A, B, C, D, E, F, G, H, I, J)> where
    A: Iterator,
    B: Iterator,
    C: Iterator,
    D: Iterator,
    E: Iterator,
    F: Iterator,
    G: Iterator,
    H: Iterator,
    I: Iterator,
    J: Iterator
type Item = (A::Item, B::Item, C::Item, D::Item, E::Item, F::Item, G::Item, H::Item, I::Item, J::Item);impl<A, B, C, D, E, F, G, H, I, J, K> Iterator for Zip<(A, B, C, D, E, F, G, H, I, J, K)> where
    A: Iterator,
    B: Iterator,
    C: Iterator,
    D: Iterator,
    E: Iterator,
    F: Iterator,
    G: Iterator,
    H: Iterator,
    I: Iterator,
    J: Iterator,
    K: Iterator
type Item = (A::Item, B::Item, C::Item, D::Item, E::Item, F::Item, G::Item, H::Item, I::Item, J::Item, K::Item);impl<A, B, C, D, E, F, G, H, I, J, K, L> Iterator for Zip<(A, B, C, D, E, F, G, H, I, J, K, L)> where
    A: Iterator,
    B: Iterator,
    C: Iterator,
    D: Iterator,
    E: Iterator,
    F: Iterator,
    G: Iterator,
    H: Iterator,
    I: Iterator,
    J: Iterator,
    K: Iterator,
    L: Iterator
type Item = (A::Item, B::Item, C::Item, D::Item, E::Item, F::Item, G::Item, H::Item, I::Item, J::Item, K::Item, L::Item);
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.

Note: The result of this macro is a value of a named type (Zip<(I, J, ..)> of each component iterator I, J, ...) if each component iterator is nameable.

Prefer izip!() over multizip for the performance benefits of using the standard library .zip(). Prefer multizip if a nameable type is needed.

use itertools::multizip;

// iterate over three sequences side-by-side
let mut results = [0, 0, 0, 0];
let inputs = [3, 7, 9, 6];

for (r, index, input) in multizip((&mut results, 0..10, &inputs)) {
    *r = index * 10 + input;
}

assert_eq!(results, [0 + 3, 10 + 7, 29, 36]);