rust/src/test/run-pass/rebind-fn.rs
Brian Anderson 518dc52f85 Reformat
This changes the indexing syntax from .() to [], the vector syntax from ~[] to
[] and the extension syntax from #fmt() to #fmt[]
2011-08-20 11:04:00 -07:00

9 lines
228 B
Rust

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