SHARE
TWEET

Untitled

a guest Feb 23rd, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top