Closed
Description
This code fails to compile:
fn main() {
let x = vec![1i, 2, 3];
let _x = x;
println!("{}", x);
}
<anon>:4:20: 4:21 error: use of moved value: `x`
<anon>:4 println!("{}", x);
^
note: in expansion of format_args!
<std macros>:2:23: 2:77 note: expansion site
<std macros>:1:1: 3:2 note: in expansion of println!
<anon>:4:5: 4:23 note: expansion site
<anon>:3:9: 3:11 note: `x` moved here because it has type `collections::vec::Vec<int>`, which is moved by default (use `ref` to override)
<anon>:3 let _x = x;
^~
Where as this compiles with no error:
fn main() {
let x = vec![1i, 2, 3];
let _ = x;
println!("{}", x);
}
[1, 2, 3]