Guest User

Untitled

a guest
Dec 14th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. pub trait AnimalT {
  2. fn num_legs(&self) -> isize;
  3. }
  4.  
  5.  
  6. pub struct Cat {}
  7.  
  8. impl AnimalT for Cat {
  9. fn num_legs(&self) -> isize { unimplemented!() }
  10. }
  11.  
  12. pub struct Wrapper<'a, T: ?Sized> {
  13. pub animal: &'a T,
  14. }
  15.  
  16. pub fn foo<'a>(animal: Wrapper<'a, AnimalT>) {
  17. }
  18.  
  19. #[test]
  20. fn test() {
  21. let c = Cat{};
  22. let f = Wrapper { animal: &c as &(dyn AnimalT + 'static) };
  23. foo(f);
  24.  
  25. }
Add Comment
Please, Sign In to add comment