Skip to content
Quiz · Closures and iterators · lesson 4 of 7

Quiz — a closure that changes a counter

What happens when this program is built and run?

Rust
fn main() {
    let mut count = 0;
    let inc = || count += 1;
    inc();
    println!("{count}");
}