Created
February 23, 2015 20:27
-
-
Save Centril/2c82c17007ad44903535 to your computer and use it in GitHub Desktop.
Trait & struct have the same name for a method
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
fn main() { | |
let b = B; | |
(&b as &A).a(); | |
} | |
trait A { | |
fn a( &self ); | |
} | |
struct B; | |
impl B { | |
fn a( &self ) { | |
println!( "World!"); | |
} | |
} | |
impl A for B { | |
fn a( &self ) { | |
println!( "Hello" ); | |
self.a(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prints: