Skip to content

Instantly share code, notes, and snippets.

@sophiajt
Last active February 13, 2016 15:41
Show Gist options
  • Save sophiajt/7d116048fd85adcb698b to your computer and use it in GitHub Desktop.
Save sophiajt/7d116048fd85adcb698b to your computer and use it in GitHub Desktop.
fn simple_fn(x: i32) -> i32 {
x + 100
}
trait FooFn {
fn foo(&self);
}
impl FooFn for Fn(i32)->i32 {
fn foo(&self) {
println!("Function foo!");
}
}
fn main() {
//Works
//let f : fn(i32)->i32 = simple_fn;
//f.foo();
//error: no method named `foo` found for type `fn(i32) -> i32 {simple_fn}` in the current scope
simple_fn.foo();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment