Skip to content

Instantly share code, notes, and snippets.

@takscape
Created January 26, 2015 11:24
Show Gist options
  • Save takscape/b95d1abac9cf96357518 to your computer and use it in GitHub Desktop.
Save takscape/b95d1abac9cf96357518 to your computer and use it in GitHub Desktop.
fn call_f<F>(f: &F) -> i32 where F: ?Sized, F: Fn(i32) -> i32 {
f(100)
}
fn main() {
let f : Box<Fn(i32) -> i32> = Box::new(|&: x| 2 * x);
let v : i32 = call_f(&*f);
println!("{}", v);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment