Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement