mirror of
https://github.com/rust-lang/book.git
synced 2026-12-04 13:24:55 -06:00
Extract error message updates to send to nostarch
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
Please view this file in monospace to see how the error messages should line up vertically.
|
||||
|
||||
Here is the new error message for page 70, I've included the whole message for clarity:
|
||||
|
||||
```
|
||||
error[E0499]: cannot borrow `s` as mutable more than once at a time
|
||||
--> src/main.rs:5:14
|
||||
|
|
||||
4 | let r1 = &mut s;
|
||||
| ------ first mutable borrow occurs here
|
||||
5 | let r2 = &mut s;
|
||||
| ^^^^^^ second mutable borrow occurs here
|
||||
6 |
|
||||
7 | println!("{}, {}", r1, r2);
|
||||
| -- first borrow later used here
|
||||
```
|
||||
|
||||
For page 71:
|
||||
|
||||
```
|
||||
error[E0502]: cannot borrow `s` as mutable because it is also borrowed as immutable
|
||||
--> src/main.rs:6:14
|
||||
|
|
||||
4 | let r1 = &s; // no problem
|
||||
| -- immutable borrow occurs here
|
||||
5 | let r2 = &s; // no problem
|
||||
6 | let r3 = &mut s; // BIG PROBLEM
|
||||
| ^^^^^^ mutable borrow occurs here
|
||||
7 |
|
||||
8 | println!("{}, {}, and {}", r1, r2, r3);
|
||||
| -- immutable borrow later used here
|
||||
```
|
||||
|
||||
For page 77:
|
||||
|
||||
```
|
||||
error[E0502]: cannot borrow `s` as mutable because it is also borrowed as immutable
|
||||
--> src/main.rs:18:5
|
||||
|
|
||||
16 | let word = first_word(&s);
|
||||
| -- immutable borrow occurs here
|
||||
17 |
|
||||
18 | s.clear(); // error!
|
||||
| ^^^^^^^^^ mutable borrow occurs here
|
||||
19 |
|
||||
20 | println!("the first word is: {}", word);
|
||||
| ---- immutable borrow later used here
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user