Advertisement
cwchen

[Rust] Implementing Drive trait in different car classes

Aug 28th, 2017
3,325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.35 KB | None | 0 0
  1. pub struct Toyota;
  2.  
  3. impl Drive for Toyota {
  4.     fn drive(&self) {
  5.         println!("Driving a Toyota car");
  6.     }
  7. }
  8.  
  9. pub struct Honda;
  10.  
  11. impl Drive for Honda {
  12.     fn drive(&self) {
  13.         println!("Driving a Honda car");
  14.     }
  15. }
  16.  
  17. pub struct Ford;
  18.  
  19. impl Drive for Ford {
  20.     fn drive(&self) {
  21.         println!("Driving a Ford car");
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement