Guest User

Untitled

a guest
Sep 12th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. trait Super {}
  2. trait Sub: Super {}
  3.  
  4. struct A<T> { a: T }
  5. struct B<T> { b: T }
  6.  
  7. trait Trait { type SomeType; }
  8.  
  9. impl<'a, T> A<T>
  10. where
  11. T: Trait,
  12. T::SomeType: Super,
  13. {
  14. fn some_type_is_super(&self) {}
  15. }
  16.  
  17. //impl<'a, T> B<T> where T: Trait<SomeType = &'a Super> { // Works
  18. impl<T> B<T>
  19. where
  20. T: Trait,
  21. T::SomeType: Sub,
  22. { // Doesn't work
  23. fn some_type_is_sub(&self, a: A<T>) {
  24. // It should be possible to call "some_type_is_super" from `A` since
  25. // Sub has the `Super` trait bound. Why it doesn't work?
  26. let _ = a.some_type_is_super();
  27. }
  28. }
Add Comment
Please, Sign In to add comment