Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. fn main() {
  2. let f = Foo;
  3. f.func_self_used();
  4.  
  5. println!("-------------------------");
  6.  
  7. let f = Foo;
  8. f.func_call_without_self();
  9. }
  10.  
  11. struct Foo;
  12.  
  13. impl Drop for Foo {
  14. fn drop(&mut self) {
  15. println!("Dropped Foo");
  16. }
  17. }
  18.  
  19. impl Foo {
  20. fn func_self_used(self) {
  21. println!("Before fn call");
  22. self.func_self_unused();
  23. println!("After fn call");
  24. }
  25.  
  26. fn func_call_without_self(self) {
  27. println!("Before fn call, without self");
  28. Self::func_without_self();
  29. println!("After fn call, without self");
  30. }
  31.  
  32. fn func_self_unused(self) {
  33. println!("Fn call with self");
  34. }
  35.  
  36. fn func_without_self() {
  37. println!("Fn call with self");
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement