Created
January 14, 2019 12:58
-
-
Save rust-play/2167e73325daa1e2a179505209405917 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains 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
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