SHARE
TWEET

Untitled

a guest Oct 20th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struct A;
  2.  
  3. trait T {
  4.     fn f(&self);
  5.     fn g(self);
  6. }
  7.  
  8. impl T for A {
  9.     fn f(&self) {
  10.         println!("T::f()");
  11.     }
  12.    
  13.     fn g(self) {
  14.         println!("T::g()");
  15.     }
  16. }
  17.  
  18. impl T for &A {
  19.     fn f(&self) {
  20.         println!("(&T)::f()");
  21.     }
  22.  
  23.     fn g(self) {
  24.         println!("(&T)::g()");
  25.     }
  26. }
  27.  
  28. fn main() {
  29.     let a1 = A;
  30.     a1.f();
  31.     a1.g();
  32.     let a2 = &A;
  33.     a2.f();
  34.     a2.g();
  35.     let a3 = &&A;
  36.     a3.f();
  37.     a3.g();
  38. }
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