Closed
Description
This one is really weird. It's the same code, but one is a Vec and one is a i32. The Vec one compiles, the i32 one doesn't:
fn vec() {
let mut _x = vec!['c'];
let _y = &_x;
_x = Vec::new();
}
fn int() {
let mut _x = 5;
let _y = &_x;
_x = 7;
}
Error:
error[E0506]: cannot assign to `_x` because it is borrowed
--> src\lib.rs:49:5
|
48 | let _y = &_x;
| --- borrow of `_x` occurs here
49 | _x = 7;
| ^^^^^^ assignment to borrowed `_x` occurs here