2012-12-10 17:32:48 -08:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2013-01-25 22:46:32 -08:00
|
|
|
struct Pair<A,B> {
|
2012-01-18 15:42:00 -08:00
|
|
|
a: A, b: B
|
2013-01-25 22:46:32 -08:00
|
|
|
}
|
2012-01-18 15:42:00 -08:00
|
|
|
|
2013-01-25 22:46:32 -08:00
|
|
|
enum RecEnum<A> = Rec<A>;
|
|
|
|
struct Rec<A> {
|
2012-01-19 10:21:42 -08:00
|
|
|
val: A,
|
2013-02-22 16:08:16 -08:00
|
|
|
rec: Option<@mut RecEnum<A>>
|
2013-01-25 22:46:32 -08:00
|
|
|
}
|
2012-01-19 10:21:42 -08:00
|
|
|
|
2012-09-07 14:52:28 -07:00
|
|
|
fn make_cycle<A:Copy>(a: A) {
|
2013-02-22 16:08:16 -08:00
|
|
|
let g: @mut RecEnum<A> = @mut RecEnum(Rec {val: a, rec: None});
|
2012-08-20 12:23:37 -07:00
|
|
|
g.rec = Some(g);
|
2012-01-19 10:21:42 -08:00
|
|
|
}
|
|
|
|
|
2013-02-20 17:07:17 -08:00
|
|
|
fn f<A:Owned + Copy,B:Owned + Copy>(a: A, b: B) -> fn@() -> (A, B) {
|
2012-01-19 10:21:42 -08:00
|
|
|
fn@() -> (A, B) { (a, b) }
|
2012-01-18 15:42:00 -08:00
|
|
|
}
|
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2012-01-18 15:42:00 -08:00
|
|
|
let x = 22_u8;
|
|
|
|
let y = 44_u64;
|
2012-01-19 10:21:42 -08:00
|
|
|
let z = f(~x, y);
|
|
|
|
make_cycle(z);
|
|
|
|
let (a, b) = z();
|
2012-08-22 17:24:52 -07:00
|
|
|
debug!("a=%u b=%u", *a as uint, b as uint);
|
2012-01-18 15:42:00 -08:00
|
|
|
assert *a == x;
|
2012-01-19 10:21:42 -08:00
|
|
|
assert b == y;
|
2013-02-14 11:47:00 -08:00
|
|
|
}
|