2018-08-30 14:18:55 +02:00
|
|
|
//@ run-pass
|
2018-08-31 15:02:01 +02:00
|
|
|
#![allow(non_camel_case_types)]
|
|
|
|
|
2015-03-22 13:13:15 -07:00
|
|
|
|
2013-12-09 23:16:18 -08:00
|
|
|
struct boxed_int<'a> {
|
2015-03-25 17:06:52 -07:00
|
|
|
f: &'a isize,
|
2012-08-09 09:59:50 -07:00
|
|
|
}
|
|
|
|
|
2015-03-25 17:06:52 -07:00
|
|
|
fn max<'r>(bi: &'r boxed_int, f: &'r isize) -> isize {
|
2012-08-09 09:59:50 -07:00
|
|
|
if *bi.f > *f {*bi.f} else {*f}
|
|
|
|
}
|
|
|
|
|
2015-03-25 17:06:52 -07:00
|
|
|
fn with(bi: &boxed_int) -> isize {
|
2012-08-09 09:59:50 -07:00
|
|
|
let i = 22;
|
|
|
|
max(bi, &i)
|
|
|
|
}
|
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2012-08-09 09:59:50 -07:00
|
|
|
let g = 21;
|
|
|
|
let foo = boxed_int { f: &g };
|
2013-05-18 22:02:45 -04:00
|
|
|
assert_eq!(with(&foo), 22);
|
2013-02-14 11:47:00 -08:00
|
|
|
}
|