fn main() {
let a = &mut 1;
let b: &mut i32 = a;
// let b = a;
a;
}
The above works, but switching out let b
line for the commented-out line below produces the following error:
error[E0382]: use of moved value: `a`
--> src/junk.rs:5:5
|
2 | let a = &mut 1;
| - move occurs because `a` has type `&mut i32`, which does not implement the `Copy` trait
3 | // let b: &mut i32 = a;
4 | let b = a;
| - value moved here
5 | a;
| ^ value used here after move
My questions are:
- What are the semantic differences between the two versions?
- Is there a difference in types between
b
in the two versions?