Crates.io | zip_eq |
lib.rs | zip_eq |
version | 0.1.0 |
source | src |
created_at | 2022-03-21 12:55:11.491416 |
updated_at | 2022-03-21 12:55:11.491416 |
description | Zip iterator that check that its inputs have the same length. |
homepage | |
repository | https://github.com/kitegi/zip-eq/ |
max_upload_size | |
id | 554079 |
size | 29,086 |
A zip iterator that checks that its inputs have the same lengths, either eagerly at the moment of construction, or lazily.
Eager check
use zip_eq::ZipEq;
let a = [1, 2];
let b = [3, 4];
let mut zipped = a.zip_eq_eager(b); // length check happens here
assert_eq!(zipped.next(), Some((1, 3)));
assert_eq!(zipped.next(), Some((2, 4)));
assert_eq!(zipped.next(), None);
Lazy check
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); // length check happens here