Created
October 8, 2014 21:02
-
-
Save kerinin/ec3fb3d1dc5c710699b2 to your computer and use it in GitHub Desktop.
Traits
This file contains hidden or 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
pub trait Fooable { | |
pub fn foo(); | |
} | |
pub impl Fooable for String { | |
pub fn foo() { | |
println!("Hello world"); | |
} | |
} |
This file contains hidden or 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
use foo::Fooable; | |
fn main() { | |
"string".to_string().foo(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment