Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created January 14, 2019 12:58
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 rust-play/2167e73325daa1e2a179505209405917 to your computer and use it in GitHub Desktop.
Save rust-play/2167e73325daa1e2a179505209405917 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
fn do_twice(f: fn(i32) -> i32, arg: i32) -> i32 { // definition
f(arg) + f(arg)
}
fn main() {
do_twice(|x| x + 1, 5); // call
let inc = 2;
do_twice(|x| x + inc, 5); // fail
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment