Iterate and collect in Rust

Rust

Filter and map fuse into a single pass; collect decides what comes out the other end.

let names: Vec<String> = users
    .iter()
    .filter(|u| u.active)
    .map(|u| u.name.to_uppercase())
    .collect();

More in Systems

Random picks