11
zip in std::iter - Rust
source link: https://doc.rust-lang.org/stable/std/iter/fn.zip.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Function std::iter::zip1.59.0[−][src]
Converts the arguments to iterators and zips them.
See the documentation of Iterator::zip
for more.
Examples
use std::iter::zip;
let xs = [1, 2, 3];
let ys = [4, 5, 6];
let mut iter = zip(xs, ys);
assert_eq!(iter.next().unwrap(), (1, 4));
assert_eq!(iter.next().unwrap(), (2, 5));
assert_eq!(iter.next().unwrap(), (3, 6));
assert!(iter.next().is_none());
// Nested zips are also possible:
let zs = [7, 8, 9];
let mut iter = zip(zip(xs, ys), zs);
assert_eq!(iter.next().unwrap(), ((1, 4), 7));
assert_eq!(iter.next().unwrap(), ((2, 5), 8));
assert_eq!(iter.next().unwrap(), ((3, 6), 9));
assert!(iter.next().is_none());
RunRecommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK