Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #![allow(warnings)]
  2.  
  3. struct Foo(usize);
  4.  
  5. impl Clone for Foo {
  6. fn clone(&self) -> Self {
  7. Self(self.0 + 1000)
  8. }
  9. }
  10.  
  11. impl Drop for Foo {
  12. fn drop(&mut self) {
  13. println!("dropping {}", self.0)
  14. }
  15. }
  16.  
  17. fn main() {
  18. let foo0 = Foo(0);
  19. let foo1 = Foo(1);
  20. let foo2 = Foo(2);
  21. foo2.clone();
  22. println!("The println! after the clone at main");
  23. let foo3 = Foo(3);
  24. let foo3 = Foo(33);
  25. foo0;
  26. println!("The println! at the end of main");
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement