Skip to content
← Index | Lesson 4 of 5

zip and chain

Iter.zip and Iter.chain

zip combines two iterators into pairs, chain concatenates:

use std::Iter

let a = [1, 2, 3]
let b = [4, 5, 6]

let zipped = Iter::from(a).zip(Iter::from(b)).collect()
// [[1,4], [2,5], [3,6]]

let chained = Iter::from(a).chain(Iter::from(b)).collect()
// [1, 2, 3, 4, 5, 6]

Goal: Use Iter.zip to combine names and scores into pairs.

lesson-6-4.zolo
Program output

Run the code to see the output

Search Zolo

9 results

enespt-br