Created
June 18, 2014 01:06
-
-
Save tomjakubowski/0bf9f1bf577e968956bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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