rustlings/solutions/06_move_semantics/move_semantics6.rs

15 lines
250 B
Rust

fn main() {
let mut counter = 0;
let mut increment = || {
counter += 1;
println!("counter equals {}", counter);
};
increment();
increment();
let _reborrowed_counter = &counter;
assert_eq!(counter, 2);
}