rust/src/test/run-pass/generic-temporary.rs

17 lines
322 B
Rust
Raw Normal View History

2012-08-01 19:30:05 -05:00
fn mk() -> int { return 1; }
fn chk(&&a: int) { log(debug, a); assert (a == 1); }
fn apply<T>(produce: extern fn() -> T,
consume: extern fn(T)) {
consume(produce());
}
fn main() {
let produce: extern fn() -> int = mk;
let consume: extern fn(&&int) = chk;
apply::<int>(produce, consume);
}