Skip to content

Instantly share code, notes, and snippets.

@emk
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emk/a05bdbfe9b71582a39f6 to your computer and use it in GitHub Desktop.
Save emk/a05bdbfe9b71582a39f6 to your computer and use it in GitHub Desktop.
Implementing traits for function types?
// Based on:
// https://github.com/emk/jit.rs/blob/master/src/macros.rs#L41-L64
// https://github.com/emk/jit.rs/blob/master/src/compile.rs#L105-L109
// https://github.com/emk/jit.rs/blob/master/examples/hello_world.rs#L22
// Build on branch:
// https://github.com/emk/jit.rs/tree/rust-beta-updates
trait Foo {}
impl Foo for fn() {}
fn do_foo<T: Foo>(t: T) {}
fn example() {}
fn main() {
do_foo(example);
}
# fn_impl.rs:10:5: 10:11 error: the trait `Foo` is not implemented for the type `fn() {example}` [E0277]
# fn_impl.rs:10 do_foo(example);
# ^~~~~~
# error: aborting due to previous error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment