daily pastebin goal
48%
SHARE
TWEET

Untitled

a guest Sep 12th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top