Guest User

Untitled

a guest
Jan 21st, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. use std::string::ToString;
  2.  
  3. trait Foo: ToString {}
  4.  
  5. struct Bar {}
  6.  
  7. impl ToString for Bar {
  8. fn to_string(&self) -> String {
  9. String::from("Bar")
  10. }
  11. }
  12.  
  13. impl Foo for Bar {}
  14.  
  15. struct Baz {}
  16.  
  17. impl ToString for Baz {
  18. fn to_string(&self) -> String {
  19. String::from("Baz")
  20. }
  21. }
  22.  
  23. impl Foo for Baz {}
  24.  
  25. fn main() {
  26. let b1: &Foo = &Bar {};
  27. let b2: &Foo = &Baz {};
  28. let _v: Vec<&Foo> = vec!(b1, b2);
  29. }
Add Comment
Please, Sign In to add comment