box.rs 398 B

1234567891011121314151617181920212223
  1. extern crate ralloc;
  2. fn alloc_box() -> Box<u32> {
  3. Box::new(0xDEADBEAF)
  4. }
  5. fn main() {
  6. let mut a = Box::new(1);
  7. let mut b = Box::new(2);
  8. let mut c = Box::new(3);
  9. assert_eq!(*a, 1);
  10. assert_eq!(*b, 2);
  11. assert_eq!(*c, 3);
  12. assert_eq!(*alloc_box(), 0xDEADBEAF);
  13. *a = 0;
  14. *b = 0;
  15. *c = 0;
  16. assert_eq!(*a, 0);
  17. assert_eq!(*b, 0);
  18. assert_eq!(*c, 0);
  19. }