/src/test/run-pass/box-unbox.rs

http://github.com/jruderman/rust · Rust · 12 lines · 8 code · 4 blank · 0 comment · 1 complexity · 1b9ca10e88e73a464e4b8ffbbada827c MD5 · raw file

  1. type box<T: copy> = {c: @T};
  2. fn unbox<T: copy>(b: box<T>) -> T { return *b.c; }
  3. fn main() {
  4. let foo: int = 17;
  5. let bfoo: box<int> = {c: @foo};
  6. debug!{"see what's in our box"};
  7. assert (unbox::<int>(bfoo) == foo);
  8. }