Skip to content

Instantly share code, notes, and snippets.

@Mr-Byte
Created September 4, 2013 03:17
Show Gist options
  • Save Mr-Byte/6432405 to your computer and use it in GitHub Desktop.
Save Mr-Byte/6432405 to your computer and use it in GitHub Desktop.
extern "C" fn foo()
{
println("Hello, world!");
}
struct Bar
{
Foo: extern "C" fn()
}
fn main()
{
let bar = Bar { Foo: foo };
bar.Foo(); //Fails:
/*
.\test.rs:15:1: 15:11 error: type `Bar` does not implement any method in scope named `Foo`
.\test.rs:15 bar.Foo();
*/
//Compiles
let baz = bar.Foo;
baz();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment