File tree 1 file changed +24
-8
lines changed
1 file changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -139,20 +139,36 @@ and [RFC 809] for more details.
139
139
"## ,
140
140
141
141
E0067 : r##"
142
- The left-hand side of an assignment operator must be an lvalue expression. An
143
- lvalue expression represents a memory location and includes item paths (ie,
144
- namespaced variables), dereferences, indexing expressions, and field
145
- references.
142
+ The left-hand side of a compound assignment expression (or compound assignment
143
+ operator) must be an lvalue expression. An lvalue expression represents a
144
+ memory location and includes item paths (ie, namespaced variables),
145
+ dereferences, indexing expressions, and field references.
146
146
147
+ Let's start with some bad examples:
147
148
```
148
149
use std::collections::LinkedList;
149
150
150
- // Good
151
- let mut list = LinkedList::new();
152
-
153
-
154
151
// Bad: assignment to non-lvalue expression
155
152
LinkedList::new() += 1;
153
+
154
+ // ...
155
+
156
+ fn some_func(i: &mut i32) {
157
+ i += 12; // Error : '+=' operation cannot be applied on a reference !
158
+ }
159
+
160
+ And now some good examples:
161
+ ```
162
+ let mut i : i32 = 0;
163
+
164
+ i += 12; // Good !
165
+
166
+ // ...
167
+
168
+ fn some_func(i: &mut i32) {
169
+ *i += 12; // Good !
170
+ }
171
+
156
172
```
157
173
"## ,
158
174
You can’t perform that action at this time.
0 commit comments