2012-06-29 16:26:56 -07:00
|
|
|
fn want_slice(v: &[int]) -> int {
|
2012-05-31 14:02:39 -07:00
|
|
|
let mut sum = 0;
|
2012-09-18 21:41:13 -07:00
|
|
|
for vec::each(v) |i| { sum += i; }
|
2012-08-01 17:30:05 -07:00
|
|
|
return sum;
|
2012-05-31 14:02:39 -07:00
|
|
|
}
|
|
|
|
|
2012-06-29 16:26:56 -07:00
|
|
|
fn has_mut_vec(+v: @~[mut int]) -> int {
|
2012-09-11 21:25:01 -07:00
|
|
|
want_slice(*v) //~ ERROR illegal borrow unless pure
|
2012-06-30 12:23:59 +01:00
|
|
|
//~^ NOTE impure due to access to impure function
|
2012-05-31 14:02:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2012-06-29 16:26:56 -07:00
|
|
|
assert has_mut_vec(@~[mut 1, 2, 3]) == 6;
|
2012-05-31 14:02:39 -07:00
|
|
|
}
|