blob: 95669309b3bc9de69951b67e674fb1f40d33c637 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
This error occurs because you tried to mutably borrow a non-mutable variable.
Erroneous code example:
```compile_fail,E0596
let x = 1;
let y = &mut x; // error: cannot borrow mutably
```
In here, `x` isn't mutable, so when we try to mutably borrow it in `y`, it
fails. To fix this error, you need to make `x` mutable:
```
let mut x = 1;
let y = &mut x; // ok!
```
|