File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -275,17 +275,21 @@ let mut a = &mut i;
275
275
// error: cannot borrow `i` as mutable more than once at a time
276
276
```
277
277
278
- Please note that in rust, you can have as many reference on a variable as you
279
- want, but only one can be mutable. Example:
278
+ Please note that in rust, you can either have many immutable references, or one
279
+ mutable reference. Take a look at
280
+ https://doc.rust-lang.org/stable/book/references-and-borrowing.html for more
281
+ information. Example:
280
282
281
283
282
284
```
283
285
let mut i = 0;
284
- let mut x = &mut i;
285
- let mut a = &i;
286
- let mut b = &i;
287
- let mut c = &i;
288
- // ...
286
+ let mut x = &mut i; // ok!
287
+
288
+ // or:
289
+ let mut i = 0;
290
+ let a = &i; // ok!
291
+ let b = &i; // still ok!
292
+ let c = &i; // super still ok!
289
293
```
290
294
"## ,
291
295
You can’t perform that action at this time.
0 commit comments