Closed
Description
fn f(_a: &mut [int, ..2]) {
}
fn g(a: &mut [int, ..2]) {
f(a);
a[1] = 2;
}
fn main() {
let mut a = [1, 2];
g(&mut a);
}
a.rs:6:5: 6:6 error: use of moved value: `a`
a.rs:6 a[1] = 2;
^
a.rs:5:7: 5:8 note: `a` moved here because it has type `&mut [int, .. 2]`, which is non-copyable (perhaps you meant to use clone()?)
a.rs:5 f(a);
^
Workaround:
struct S { s: [int, ..2] }
fn f(_a: &mut S) {
}
fn g(a: &mut S) {
f(a);
a.s[1] = 2; // ok
}
fn main() {
let mut a = S { s: [1, 2] };
g(&mut a);
}
Metadata
Metadata
Assignees
Labels
No labels