Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #[derive(Debug)]
  2. struct S(u32);
  3.  
  4. fn move_struct() -> S {
  5. let s = S(0);
  6. println!("addr before move: {:p}", &s);
  7. s
  8. }
  9.  
  10. fn move_box() -> Box<S> {
  11. let s_box = Box::new(S(0));
  12. println!("addr before box move: {:p}", &*s_box);
  13. s_box
  14. }
  15.  
  16. fn main() {
  17. let s = move_struct();
  18. println!(">addr after move: {:p}", &s);
  19.  
  20. let s_box = move_box();
  21. println!(">addr after box move: {:p}", &*s_box);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement