Skip to main content

zip_eq

Function zip_eq 

Source
pub fn zip_eq<A: IntoIterator, B: IntoIterator>(
    a: A,
    b: B,
) -> ZipEq<A::IntoIter, B::IntoIter> 
Expand description

Zips two iterators, panicking if one is exhausted before the other.

Use this over Iterator::zip when equal lengths are an invariant: zip silently truncates to the shorter side, hiding the mismatch.

§Examples

use commonware_utils::iter::zip_eq;

let pairs: Vec<_> = zip_eq([1, 2], ["a", "b"]).collect();
assert_eq!(pairs, vec![(1, "a"), (2, "b")]);