[−][src]Trait higher_order_functions::Zip
Zip two collections using a function to combine pairs of elements.
Examples
Zipping two arrays of different types into a single array of tuples:
use higher_order_functions::Zip; let a = [1, 2, 3]; let b = ["a", "b", "c"]; let arr = a.zip(b, |ax, bx| (ax, bx)); assert_eq!(arr, [(1, "a"), (2, "b"), (3, "c")]);
Zipping two arrays by multiplying each pair of elements:
use higher_order_functions::Zip; let a = [1, 2, 3]; let b = [4, 5, 6]; let arr = a.zip(b, |ax, bx| ax * bx); assert_eq!(arr, [4, 10, 18]);
Associated Types
type TLhs
The type parameter of Self
.
Self: TSelf<TLhs>
type TSelf
The generic type of Self
.
Self: TSelf<TLhs>
Required methods
fn zip<TRhs, TTo, F: FnMut(Self::TLhs, TRhs) -> TTo>(
self,
rhs: Self::TSelf,
f: F
) -> Self::TSelf
self,
rhs: Self::TSelf,
f: F
) -> Self::TSelf
Apply f
to each pair of elements in self
and rhs
and return the results.
Implementations on Foreign Types
impl<TLhs, const N: usize> Zip for [TLhs; N]
[src]
Zip two arrays using a function to combine pairs of elements.
type TLhs = TLhs
type TSelf = [T; N]
fn zip<TRhs, TTo, F: FnMut(Self::TLhs, TRhs) -> TTo>(
self,
rhs: Self::TSelf,
f: F
) -> Self::TSelf
[src]
self,
rhs: Self::TSelf,
f: F
) -> Self::TSelf