rust/src/test/run-pass/rebind-fn.rs

9 lines
224 B
Rust

fn add(i: int, j: int) -> int { ret i + j; }
fn binder(n: int) -> fn@() -> int { let f = add(n, _); ret bind f(2); }
fn main() {
binder(5);
let f = binder(1);
assert (f() == 3);
assert (binder(8)() == 10);
}