Beginner Rust
Q31 / 100

What is an iterator in Rust?

Correct! Well done.

Incorrect.

The correct answer is B) A trait (Iterator) with a next() method, enabling lazy consumption of sequences with adaptors like map, filter, and collect

B

Correct Answer

A trait (Iterator) with a next() method, enabling lazy consumption of sequences with adaptors like map, filter, and collect

Explanation

v.iter().filter(|x| *x > 2).map(|x| x * 2).collect::<Vec<_>>() chains lazy iterator adaptors, executing only on collect().

Progress
31/100