Crates.io | zip-fill |
lib.rs | zip-fill |
version | 1.0.0 |
source | src |
created_at | 2021-07-22 00:15:48.035269 |
updated_at | 2021-07-22 00:15:48.035269 |
description | Iterator library |
homepage | https://gitlab.com/daingun/zip-fill |
repository | https://gitlab.com/daingun/zip-fill |
max_upload_size | |
id | 425724 |
size | 42,737 |
Zip two iterators, if they have different length, the shortest is extended using a default value.
The two iterators must have the same Item
type.
It is similar to zip_longest
algorithm from the itertool
python library.
use zip_fill::ZipFill;
let a = [ 1, 2, 3, 4];
let b = [ 1, 2];
let z: Vec<_> = a.iter().zip_longest(&b, &0).collect();
assert_eq!(vec!((&1, &1), (&2, &2), (&3, &0), (&4, &0)), z);
let z: Vec<_> = zip_fill::zip_longest_with(&a, &b, &0, |a, b| a + b).collect();
assert_eq!(vec!(2, 4, 3, 4), z);
Minimum tested rustc version: 1.44