Last active
September 25, 2016 01:48
-
-
Save dumindu/e1423ebf9d8a40a0a0c0 to your computer and use it in GitHub Desktop.
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
fn plus_one(a: i32) -> i32 { | |
a + 1 | |
} | |
let b = plus_one; | |
let c = b(5); //6 | |
let b: fn(i32) -> i32 = plus_one; //same, with type inference | |
let c = b(5); //6 | |
let b = plus_one; | |
fn plus_two(b: fn(i32) -> i32, x: i32) -> i32 { | |
b(b(x)) | |
} | |
println!("{}", plus_two(b, 2)); //4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment