Created
August 1, 2015 11:50
-
-
Save sumproxy/3dce80273cfed19ac1d6 to your computer and use it in GitHub Desktop.
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
// A function which takes a closure and returns an `i32`. | |
fn apply_to_n<F, T>(f: F, t: T) -> T where | |
// The closure takes an `i32` and returns an `i32`. | |
F: Fn(T) -> T { | |
f(t) | |
} | |
fn main() { | |
let double = |x| 2 * x; | |
println!("2 quintupled: {}", apply_to_n::<Fn, i32>(double, 5)); // problem is probably with std::ops::Fn | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment