Guest User

Untitled

a guest
Mar 23rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #![allow(warnings)]
  2.  
  3. trait Foo
  4. {
  5. type T;
  6.  
  7. fn bar(&mut self)
  8. {
  9. println!("Core Implementation!");
  10. }
  11. }
  12. impl Foo<T = i32> // What's the use of this implementation if it's not accessible?
  13. {
  14. fn bar(&mut self)
  15. {
  16. println!("Default i32 Implementation!");
  17. }
  18. }
  19.  
  20. struct Baz
  21. {
  22.  
  23. }
  24. impl Foo for Baz
  25. {
  26. type T = i32;
  27. }
  28.  
  29. // Not Allowed!
  30. // impl Foo<T=i32> for Baz
  31. // {
  32. // type T = i32;
  33. // }
  34.  
  35.  
  36. fn main()
  37. {
  38. let mut a: Box<Foo<T = i32>> = Box::new(Baz{});
  39. type Bunny = Foo<T=i32>;
  40. <Bunny as Bunny>::bar(&mut *a);
  41. }
Add Comment
Please, Sign In to add comment