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

13 lines
214 B
Rust
Raw Normal View History

type box<T> = {c: @T};
2010-06-23 23:03:09 -05:00
fn unbox<T>(b: &box<T>) -> T { ret *b.c; }
2010-06-23 23:03:09 -05:00
fn main() {
2011-07-27 07:19:39 -05:00
let foo: int = 17;
let bfoo: box<int> = {c: @foo};
log "see what's in our box";
assert (unbox[int](bfoo) == foo);
}