Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardRustZero-cost abstraction in codegenSingle-choice MCQ

An iterator chain like `(0..n).map(|x| x * 2).filter(|x| x % 3 == 0).sum()` is described as a zero-cost abstraction. After optimization, what does the generated code most closely resemble, and why?

let total: u64 = (0..n).map(|x| x * 2) .filter(|x| x % 3 == 0) .sum();