rust/src/test/run-pass/generic-temporary.rs
2011-07-27 15:54:33 +02:00

13 lines
267 B
Rust

fn mk() -> int { ret 1; }
fn chk(a: &int) { log a; assert (a == 1); }
fn apply[T](produce: fn() -> T , consume: fn(&T) ) { consume(produce()); }
fn main() {
let produce: fn() -> int = mk;
let consume: fn(&int) = chk;
apply[int](produce, consume);
}