Skip to content

Instantly share code, notes, and snippets.

@takscape
Created January 26, 2015 11:15
Show Gist options
  • Save takscape/ee3bf6553e0a6404922d to your computer and use it in GitHub Desktop.
Save takscape/ee3bf6553e0a6404922d to your computer and use it in GitHub Desktop.
fn call_f<F: ?Sized + Fn(i32) -> i32>(f: &F) -> 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