Guest User

Untitled

a guest
Jul 16th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. struct Container { pub foo: Box<Foo> }
  2.  
  3. struct Bar { a: u32 }
  4.  
  5. trait Foo {
  6. fn into_container(self: Box<Self>) -> Container where Self: Sized + 'static { Container { foo: self }}
  7. }
  8.  
  9. impl Foo for Bar {}
  10.  
  11. fn main() {
  12. let foo: Box<Foo> = Box::new(Bar{ a: 5 });
  13. foo.into_container();
  14. }
Add Comment
Please, Sign In to add comment