-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd13335
commit c981c99
Showing
3 changed files
with
24 additions
and
2,578 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
A non-mutable value was assigned a value. | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0594 | ||
struct SolarSystem { | ||
earth: i32, | ||
} | ||
let ss = SolarSystem { earth: 3 }; | ||
ss.earth = 2; // error! | ||
``` | ||
|
||
To fix this error, declare `ss` as mutable by using the `mut` keyword: | ||
|
||
``` | ||
struct SolarSystem { | ||
earth: i32, | ||
} | ||
let mut ss = SolarSystem { earth: 3 }; // declaring `ss` as mutable | ||
ss.earth = 2; // ok! | ||
``` |
Oops, something went wrong.