Created
May 9, 2014 20:50
-
-
Save sinistersnare/b656e39480372606edb5 to your computer and use it in GitHub Desktop.
Multiple Traits per impl block in Rust
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 MyFirstTrait { | |
fn my_first_func() -> (); | |
} | |
trait MySecondTrait { | |
fn my_second_func() -> (); | |
fn my_third_func() -> (); | |
} | |
struct MyStruct; | |
impl MyFirstTrait, MySecondTrait for MyStruct { //the RFC will allow this | |
fn my_first_func() -> () { println!("The first function!") } | |
fn my_second_func() -> () { println!("The second function!") } | |
fn my_third_func() -> () { println!("The third function!") } | |
} | |
//that impl would just be syntactic sugar more or less for: | |
impl MyFirstTrait for MyStruct { | |
fn my_first_func() -> () { println!("The first function!") } | |
} | |
impl MySecondTrait for MyStruct { | |
fn my_second_func() -> () { println!("The second function!") } | |
fn my_third_func() -> () { println!("The third function!") } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment