Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. struct Temporary;
  2.  
  3. impl Drop for Temporary {
  4. fn drop(&mut self) {
  5. dbg!("dropped");
  6. }
  7. }
  8.  
  9. impl Temporary {
  10. fn do_stuff(&self) -> bool {true}
  11. }
  12.  
  13. pub fn main() {
  14. dbg!("before");
  15. if Temporary.do_stuff() {
  16. dbg!("in");
  17. }
  18. dbg!("after");
  19.  
  20. dbg!("before");
  21. match { Temporary.do_stuff() } {
  22. true => { dbg!("in"); },
  23. _ => (),
  24. }
  25. dbg!("after");
  26.  
  27. dbg!("before");
  28. match { let x = Temporary.do_stuff(); x } {
  29. true => { dbg!("in"); },
  30. _ => (),
  31. }
  32. dbg!("after");
  33.  
  34. dbg!("before");
  35. match { Temporary.do_stuff() } {
  36. true => { dbg!("in"); },
  37. _ => (),
  38. }
  39. dbg!("after");
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement