Advertisement
cwchen

[Rust] Inheriting traits

Sep 4th, 2017
3,371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.24 KB | None | 0 0
  1. // Parent trait
  2. pub trait Color {
  3.     fn color<'a>(&self) -> &'a str;
  4. }
  5.  
  6. // Parent trait
  7. pub trait Shape {
  8.     fn shape<'a>(&self) -> &'a str;
  9. }
  10.  
  11. // Child trait
  12. pub trait Item: Color + Shape {
  13.     fn name<'a>(&self) -> &'a str;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement