2010-06-28 23:45:48 -05:00
|
|
|
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2011-11-18 05:39:20 -06:00
|
|
|
obj buf<copy T>(data: {_0: T, _1: T, _2: T}) {
|
2011-07-27 07:19:39 -05:00
|
|
|
fn get(i: int) -> T {
|
|
|
|
if i == 0 {
|
2011-06-15 13:19:50 -05:00
|
|
|
ret data._0;
|
2011-07-27 07:19:39 -05:00
|
|
|
} else { if i == 1 { ret data._1; } else { ret data._2; } }
|
2011-06-15 13:19:50 -05:00
|
|
|
}
|
2011-09-12 04:27:30 -05:00
|
|
|
fn take(t: T) { }
|
|
|
|
fn take2(t: T) { }
|
2010-06-23 23:03:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2011-08-13 02:10:18 -05:00
|
|
|
let b: buf<int> = buf::<int>({_0: 1, _1: 2, _2: 3});
|
2011-06-15 13:19:50 -05:00
|
|
|
log "constructed object";
|
|
|
|
log b.get(0);
|
|
|
|
log b.get(1);
|
|
|
|
log b.get(2);
|
|
|
|
assert (b.get(0) == 1);
|
|
|
|
assert (b.get(1) == 2);
|
|
|
|
assert (b.get(2) == 3);
|
|
|
|
b.take2(0);
|
2011-08-10 11:27:22 -05:00
|
|
|
}
|