2012-08-09 11:59:50 -05:00
|
|
|
struct boxed_int {
|
2012-09-07 16:50:47 -05:00
|
|
|
f: &int,
|
2012-08-09 11:59:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn max(bi: &r/boxed_int, f: &r/int) -> int {
|
|
|
|
if *bi.f > *f {*bi.f} else {*f}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn with(bi: &boxed_int) -> int {
|
|
|
|
let i = 22;
|
|
|
|
max(bi, &i)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let g = 21;
|
|
|
|
let foo = boxed_int { f: &g };
|
|
|
|
assert with(&foo) == 22;
|
|
|
|
}
|