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

13 lines
267 B
Rust
Raw Normal View History

fn mk() -> int { ret 1; }
2011-07-27 14:19:39 +02:00
fn chk(a: &int) { log a; assert (a == 1); }
2011-07-27 14:19:39 +02:00
fn apply[T](produce: fn() -> T , consume: fn(&T) ) { consume(produce()); }
fn main() {
2011-07-27 14:19:39 +02:00
let produce: fn() -> int = mk;
let consume: fn(&int) = chk;
apply[int](produce, consume);
}