You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
structS{s:[int, ..2]}fnf(_a:&mutS){}fng(a:&mutS){f(a);
a.s[1] = 2;// ok}fnmain(){letmut a = S{s:[1,2]};g(&mut a);}