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