Skip to content
Course map | Lesson 4 of 5

Iterators · 6.4

zip and chain

All lessons are open — jump whenever you need.

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

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

enespt-br