Quiz · Closures and iterators · lesson 4 of 7
Quiz — a closure that changes a counter
What happens when this program is built and run?
fn main() {
let mut count = 0;
let inc = || count += 1;
inc();
println!("{count}");
}What happens when this program is built and run?
fn main() {
let mut count = 0;
let inc = || count += 1;
inc();
println!("{count}");
}