Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. trait Foo {
  2. fn get_int(&self) -> usize;
  3. }
  4.  
  5. struct Bar {}
  6.  
  7. impl Foo for Bar {
  8. fn get_int(&self) -> usize { 0 }
  9. }
  10.  
  11. fn do_something(_f: Box<dyn Foo>) {
  12. println!("hello");
  13. }
  14.  
  15. fn main() {
  16. let x = Box::new(Bar {});
  17. do_something(x);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement