Skip to content

Commit

Permalink
Add url to rust-book
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Sep 18, 2015
1 parent bc72f54 commit 7badafa
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/librustc_borrowck/diagnostics.rs
Expand Up @@ -275,17 +275,21 @@ let mut a = &mut i;
// error: cannot borrow `i` as mutable more than once at a time
```
Please note that in rust, you can have as many reference on a variable as you
want, but only one can be mutable. Example:
Please note that in rust, you can either have many immutable references, or one
mutable reference. Take a look at
https://doc.rust-lang.org/stable/book/references-and-borrowing.html for more
information. Example:
```
let mut i = 0;
let mut x = &mut i;
let mut a = &i;
let mut b = &i;
let mut c = &i;
// ...
let mut x = &mut i; // ok!
// or:
let mut i = 0;
let a = &i; // ok!
let b = &i; // still ok!
let c = &i; // super still ok!
```
"##,

Expand Down

0 comments on commit 7badafa

Please sign in to comment.