File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -171,25 +171,33 @@ function's return type and the value being returned.
171
171
"## ,
172
172
173
173
E0070 : r##"
174
- You tried to change the value of a const variable, which is not possible. Bad
175
- example:
174
+ The left-hand side of an assignment operator must be an lvalue expression. An
175
+ lvalue expression represents a memory location and includes item paths (ie,
176
+ namespaced variables), dereferences, indexing expressions, and field references.
177
+
178
+ More details can be found here:
179
+ https://doc.rust-lang.org/reference.html#lvalues,-rvalues-and-temporaries
176
180
181
+ Now, we can go further. Here are some bad examples:
177
182
```
178
183
const SOME_CONST : i32 = 12;
179
184
180
185
fn some_function() {
181
186
SOME_CONST = 14; // error !
187
+ 1=3; // error
182
188
}
183
189
```
184
190
185
- Constant variables' value cannot be changed once it has been set. Please take a
186
- look to static keyword if you want something similar but mutable:
191
+ And now let's give good examples:
187
192
188
193
```
189
194
static mut SOME_NOT_CONST : i32 = 12;
190
195
191
196
fn some_function() {
192
197
SOME_NOT_CONST = 14; // that's good !
198
+ let mut i : i32 = 1;
199
+
200
+ i = 3; // that's good !
193
201
}
194
202
```
195
203
"## ,
You can’t perform that action at this time.
0 commit comments