Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. struct A;
  2. struct B;
  3. struct D;
  4.  
  5. trait Trait<Type1> {
  6. fn method(&self);
  7. }
  8.  
  9. impl Trait<A> for D {
  10. fn method(&self) {
  11. println!("{}", "Test");
  12. }
  13. }
  14.  
  15. impl Trait<B> for D {
  16. fn method(&self) {
  17. println!("{}", "Not a test");
  18. }
  19. }
  20.  
  21. fn main() {
  22. let v = D{};
  23. (&v as &dyn Trait<A>).method();
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement