Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. trait A {}
  2. trait B: A {}
  3.  
  4. struct C;
  5. impl A for C {}
  6. impl B for C {}
  7.  
  8.  
  9. fn foo(v: Box<A>) {}
  10.  
  11. fn main() {
  12. let c = C;
  13. let b: Box<B> = Box::new(c);
  14. foo(b); // Compile error, wrong type : Expected Box<A>, got
  15. // Box<B>
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement