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

39 lines
998 B
Rust
Raw Normal View History

// 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.
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-08-20 14:23:37 -05:00
mut rec: Option<@rec<A>>
};
fn make_cycle<A:Copy>(a: A) {
2012-08-20 14:23:37 -05:00
let g: @rec<A> = @rec({val: a, mut rec: None});
g.rec = Some(g);
}
2012-12-11 15:50:04 -06:00
fn f<A:Owned Copy, B:Owned 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();
2012-08-22 19:24:52 -05:00
debug!("a=%u b=%u", *a as uint, b as uint);
assert *a == x;
assert b == y;
}