Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #![allow(unused_variables)]
  2. #![allow(dead_code)]
  3.  
  4. use std::f32::consts::{PI, E};
  5.  
  6. struct S(f32);
  7.  
  8. //opt-in to custom drop behavior
  9. impl Drop for S {
  10. fn drop(&mut self) {
  11. println!("S::drop({:.4})", self.0);
  12. }
  13. }
  14.  
  15. fn do_with_s(s: S) {
  16. println!("do_with_s({:.10})", s.0);
  17. }
  18.  
  19. fn main() {
  20. println!("main::start");
  21.  
  22. let stack_variable = S(PI);
  23. let heap_variable = Box::new( S(E) );
  24.  
  25. do_with_s(stack_variable);
  26.  
  27. println!("main::end");
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement