Guest User

Untitled

a guest
Jun 22nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. trait TestTrait {
  2. fn say_hello(&self);
  3. }
  4.  
  5. struct TestImplementorOne;
  6.  
  7. struct TestImplementorTwo;
  8.  
  9. impl TestTrait for TestImplementorOne{
  10. fn say_hello(&self){ println!("one");}
  11. }
  12.  
  13. impl TestTrait for TestImplementorTwo {
  14. fn say_hello(&self) {println!("two");}
  15. }
  16.  
  17.  
  18.  
  19.  
  20. fn main(){
  21. let t = TestImplementorOne;
  22. t.say_hello();
  23.  
  24.  
  25. let v : Vec<TestTrait> = vec!(TestImplementorOne, TestImplementorTwo, TestImplementorOne);
  26. }
Add Comment
Please, Sign In to add comment