2011-06-15 13:19:50 -05:00
|
|
|
// -*- rust -*-
|
2011-07-27 07:19:39 -05:00
|
|
|
fn ho(f: fn(int) -> int ) -> int { let n: int = f(3); ret n; }
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
fn direct(x: int) -> int { ret x + 1; }
|
2010-06-23 23:03:09 -05:00
|
|
|
|
|
|
|
fn main() {
|
2011-07-27 07:19:39 -05:00
|
|
|
let a: int =
|
2011-06-15 13:19:50 -05:00
|
|
|
direct(3); // direct
|
2011-08-18 23:27:22 -05:00
|
|
|
let b: int = ho(direct); // indirect unbound
|
2011-07-27 07:19:39 -05:00
|
|
|
|
|
|
|
let c: int =
|
2011-06-15 13:19:50 -05:00
|
|
|
ho(bind direct(_)); // indirect bound
|
2011-08-18 23:27:22 -05:00
|
|
|
assert (a == b);
|
|
|
|
assert (b == c);
|
2011-06-15 13:19:50 -05:00
|
|
|
}
|