Last active
September 10, 2015 15:45
-
-
Save archer884/970737fc64240e106eb6 to your computer and use it in GitHub Desktop.
Rust weirdness
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This does not work without the move marker. The reason for that is that the lifetime for `a` | |
// only covers the scope of the outer function, which does not extend to the scope of the inner | |
// function, which is returned from the outer function. | |
fn main() { | |
let x = |a| move |b| a + b; | |
let y = x(5); | |
let z = y(5); | |
println!("{}", z); // prints 10 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment