rust/src/test/run-pass/borrowck-borrow-from-at-vec.rs

10 lines
174 B
Rust
Raw Normal View History

fn sum_slice(x: &[int]) -> int {
let mut sum = 0;
for x.each |i| { sum += *i; }
2012-08-01 19:30:05 -05:00
return sum;
}
fn main() {
let x = @[1, 2, 3];
assert sum_slice(x) == 6;
}