rust/src/test/run-pass/block-iter-2.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

10 lines
247 B
Rust

fn iter_vec<T>(v: &[T], f: &block(&T)) { for x: T in v { f(x); } }
fn main() {
let v = [1, 2, 3, 4, 5];
let sum = 0;
iter_vec(v, {|&i| iter_vec(v, {|&j| log_err i * j; sum += i * j; }); });
log_err sum;
assert (sum == 225);
}