mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
17 lines
324 B
Rust
17 lines
324 B
Rust
//@ run-pass
|
|
|
|
fn mk() -> isize { return 1; }
|
|
|
|
fn chk(a: isize) { println!("{}", a); assert_eq!(a, 1); }
|
|
|
|
fn apply<T>(produce: fn() -> T,
|
|
consume: fn(T)) {
|
|
consume(produce());
|
|
}
|
|
|
|
pub fn main() {
|
|
let produce: fn() -> isize = mk;
|
|
let consume: fn(v: isize) = chk;
|
|
apply::<isize>(produce, consume);
|
|
}
|