- removes various fields from various variants in the AST - also update tests not to use this notation
27 lines
496 B
Rust
27 lines
496 B
Rust
// Note: impl on a slice
|
|
impl foo for &[int] {
|
|
fn sum() -> int {
|
|
let mut sum = 0;
|
|
for vec::each(self) |e| { sum += e; }
|
|
ret sum;
|
|
}
|
|
}
|
|
|
|
fn call_sum(x: &[int]) -> int { x.sum() }
|
|
|
|
fn main() {
|
|
let x = ~[1, 2, 3];
|
|
let y = call_sum(x);
|
|
#debug["y==%d", y];
|
|
assert y == 6;
|
|
|
|
let x = ~[mut 1, 2, 3];
|
|
let y = x.sum();
|
|
#debug["y==%d", y];
|
|
assert y == 6;
|
|
|
|
let x = ~[1, 2, 3];
|
|
let y = x.sum();
|
|
#debug["y==%d", y];
|
|
assert y == 6;
|
|
} |