2012-06-29 18:26:56 -05:00
|
|
|
fn want_slice(v: &[int]) -> int {
|
2012-05-31 16:02:39 -05:00
|
|
|
let mut sum = 0;
|
2012-06-30 18:19:07 -05:00
|
|
|
for vec::each(v) |i| { sum += i; }
|
2012-05-31 16:02:39 -05:00
|
|
|
ret sum;
|
|
|
|
}
|
|
|
|
|
2012-06-29 18:26:56 -05:00
|
|
|
fn has_mut_vec(+v: @~[mut int]) -> int {
|
2012-06-30 06:23:59 -05:00
|
|
|
want_slice(*v) //~ ERROR illegal borrow unless pure: creating immutable alias to aliasable, mutable memory
|
|
|
|
//~^ NOTE impure due to access to impure function
|
2012-05-31 16:02:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2012-06-29 18:26:56 -05:00
|
|
|
assert has_mut_vec(@~[mut 1, 2, 3]) == 6;
|
2012-05-31 16:02:39 -05:00
|
|
|
}
|