这段代码有什么问题?
fn example() {
let vec = vec![1, 2, 3];
let &_y = &vec;
}
Run Code Online (Sandbox Code Playgroud)
error[E0507]: cannot move out of borrowed content
--> src/lib.rs:3:15
|
3 | let &_y = &vec;
| --- ^^^^ cannot move out of borrowed content
| ||
| |data moved here
| help: consider removing the `&`: `_y`
|
note: move occurs because `_y` has type `std::vec::Vec<i32>`, which does not implement the `Copy` trait
--> src/lib.rs:3:10
|
3 | let &_y = &vec;
| ^^ …Run Code Online (Sandbox Code Playgroud)