Zip

Macro Zip 

Source
macro_rules! Zip {
    ($head: ty $(,)?) => { ... };
    ($head: ty, $($tail: ty),* $(,)?) => { ... };
}
Expand description

expands to the type of zipped items.

ยงexample

use faer::{Mat, Zip, mat, unzip, zip};

let nrows = 2;
let ncols = 3;

let a = mat![[1.0, 3.0, 5.0], [2.0, 4.0, 6.0]];
let b = mat![[7.0, 9.0, 11.0], [8.0, 10.0, 12.0]];
let mut sum = Mat::<f64>::zeros(nrows, ncols);

zip!(&mut sum, &a, &b).for_each(|unzip!(sum, a, b): Zip!(&mut f64, &f64, &f64)| {
	*sum = a + b;
});

for i in 0..nrows {
	for j in 0..ncols {
		assert_eq!(sum[(i, j)], a[(i, j)] + b[(i, j)]);
	}
}