5 ms·
C++ and Rust do let you capture by value. Here is a Rust example that outputs exactly what you would naively expect. fn main() { let mut x = 1;
by FreeFull 7y ago
C++ and Rust do let you capture by value. Here is a Rust example that outputs exactly what you would naively expect.
fn main() {
let mut x = 1;
let f = move || println!("{}", x);
x = 2;
let g = move || println!("{}", x);
f();
g();
}