← All Exercises

Rust Vector Iteration

basicrust~15min

Background

Rust iterators provide a lazy, composable way to process collections with zero-cost abstractions.

Problem

Write a Rust function that takes a vector of integers and returns the sum of squares of even numbers using iterator methods.

Input

A vector of integers (Vec<i32>).

Output

The sum of squares of even numbers.

Sample tests

Sample 1

Input: [1, 2, 3, 4, 5, 6]
Expected: 56

Your solution

Learning objective

Learn iterator adaptors (filter, map, sum), reference patterns in closures, and zero-cost abstractions.