Skip to content

Instantly share code, notes, and snippets.

@tomjakubowski
Created June 18, 2014 01:06
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 tomjakubowski/0bf9f1bf577e968956bd to your computer and use it in GitHub Desktop.
Save tomjakubowski/0bf9f1bf577e968956bd to your computer and use it in GitHub Desktop.
trait Foo {
fn foo(_: Self) -> int {
42
}
}
struct Baz;
impl Foo for Baz { }
struct Bar { x: int }
impl Foo for Bar {
fn foo(b: Bar) -> int { b.x }
}
pub fn main() {
let bar = Bar { x: 12 };
let x = Foo::foo(bar);
println!("{}", x);
let baz = Baz;
let x = Foo::foo(baz);
println!("{}", x);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment