2018-08-30 14:18:55 +02:00
|
|
|
// run-pass
|
2011-04-13 13:21:06 -07:00
|
|
|
|
2015-03-25 17:06:52 -07:00
|
|
|
fn mk() -> isize { return 1; }
|
2011-04-13 13:21:06 -07:00
|
|
|
|
2015-06-07 21:00:38 +03:00
|
|
|
fn chk(a: isize) { println!("{}", a); assert_eq!(a, 1); }
|
2011-06-15 11:19:50 -07:00
|
|
|
|
2014-02-14 17:23:01 +13:00
|
|
|
fn apply<T>(produce: fn() -> T,
|
|
|
|
consume: fn(T)) {
|
2012-01-11 09:58:05 -08:00
|
|
|
consume(produce());
|
|
|
|
}
|
2011-04-13 13:21:06 -07:00
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2015-03-25 17:06:52 -07:00
|
|
|
let produce: fn() -> isize = mk;
|
|
|
|
let consume: fn(v: isize) = chk;
|
|
|
|
apply::<isize>(produce, consume);
|
2011-08-12 06:37:25 -07:00
|
|
|
}
|