::std::array::

Function zip

pub fn zip<L, R, #uint N>(l: [L; N], r: [R; N]) -> [(L, R); N]
Expand

Pairs elements of two arrays together into a single array of tuples.

An array is produced with the same length as both inputs provided. For each array position, the elements from both arrays are paired as a tuple and stored in the result array. In other words, given two arrays [l0, l1, l2, ...] and [r0, r1, r2, ...], the output would be [(l0, r0), (l1, r1), (l2, r2), ...].

Examples

let l = [10u8, 11u8, 12u8];
let r = [20u8, 21u8, 22u8];
assert zip(l, r) == [(10u8, 20u8), (11u8, 21u8), (12u8, 22u8)];
let empty: [uint<8>; 0] = [];
assert zip([], []) == empty;