rust/src/test/run-pass/alignment-gep-tup-like-2.rs

29 lines
529 B
Rust
Raw Normal View History

type pair<A,B> = {
a: A, b: B
};
2012-01-20 16:17:40 -06:00
enum rec<A> = _rec<A>;
type _rec<A> = {
val: A,
2012-03-26 20:35:18 -05:00
mut rec: option<@rec<A>>
};
fn make_cycle<A:copy>(a: A) {
2012-03-26 20:35:18 -05:00
let g: @rec<A> = @rec({val: a, mut rec: none});
g.rec = some(g);
}
fn f<A:send copy, B:send copy>(a: A, b: B) -> fn@() -> (A, B) {
fn@() -> (A, B) { (a, b) }
}
fn main() {
let x = 22_u8;
let y = 44_u64;
let z = f(~x, y);
make_cycle(z);
let (a, b) = z();
debug!{"a=%u b=%u", *a as uint, b as uint};
assert *a == x;
assert b == y;
}