Expand description

Zip iterator that check that its inputs have the same length.

Two types of iterators are provided. The first one that checks that the sizes are equal eagerly at the moment it’s constructed. This can be checked when the iterators’ lengths can be known and trusted to be exact (See core::iter::TrustedLen for more details). This is done using ZipEq::zip_eq_eager.
Or in the case where the user knows for certain that the lengths are equal, the check can be avoided with the unsafe method ZipEq::zip_eq_unchecked.
The second type of iterator is one that checks that the sizes are equal while it’s being iterated over. It can be constructed with ZipEq::zip_eq_lazy.

Examples:

use zip_eq::ZipEq;

let a = [1, 2];
let b = [3, 4];
let mut zipped = a.zip_eq_lazy(b);

assert_eq!(zipped.next(), Some((1, 3)));
assert_eq!(zipped.next(), Some((2, 4)));
assert_eq!(zipped.next(), None);
use zip_eq::ZipEq;

let a = [1, 2];
let b = [3, 4];
let mut zipped = a.zip_eq_eager(b);

assert_eq!(zipped.next(), Some((1, 3)));
assert_eq!(zipped.next(), Some((2, 4)));
assert_eq!(zipped.next(), None);
use zip_eq::ZipEq;

let a = [1, 2, 3];
let b = [3, 4];
let mut zipped = a.zip_eq_eager(b); // length equality check happens here.
use zip_eq::ZipEq;

let a = [1, 2, 3];
let b = [3, 4];
let mut zipped = a.zip_eq_lazy(b);

assert_eq!(zipped.next(), Some((1, 3)));
assert_eq!(zipped.next(), Some((2, 4)));
zipped.next(); // length equality check happens here.

Structs

Iterator that zips two iterators, checking that they have the same length during construction.

Iterator that zips two iterators, checking that they have the same length during iteration.

Traits

Trait that adds zip_eq_* builder functions to objects that are convertible to iterators