SHARE
TWEET

Untitled

a guest Aug 14th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fn main() {
  2.     let y_static = Y;
  3.     let y_dynamic: &dyn X = &y_static;
  4.     foo(&y_static);
  5.     foo(y_dynamic);
  6. }
  7.  
  8. trait X {
  9.     fn foo(&self);
  10. }
  11.  
  12. struct Y;
  13.  
  14. impl X for Y {
  15.     fn foo(&self) { println!("hello world!") }
  16. }
  17.  
  18. fn foo<T: ?Sized + X>(x: &T) {
  19.     x.foo()
  20. }
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