Skip to content

Instantly share code, notes, and snippets.

@archer884
Last active September 10, 2015 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save archer884/970737fc64240e106eb6 to your computer and use it in GitHub Desktop.
Save archer884/970737fc64240e106eb6 to your computer and use it in GitHub Desktop.
Rust weirdness
// 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