Skip to content

Commit

Permalink
fix code and error to match the surronding text
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Jul 31, 2015
1 parent 8d2eb59 commit 6a86a0c
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/doc/tarpl/borrow-splitting.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,27 @@ However borrowck doesn't understand arrays or slices in any way, so this doesn't
work:

```rust,ignore
let x = [1, 2, 3];
let mut x = [1, 2, 3];
let a = &mut x[0];
let b = &mut x[1];
println!("{} {}", a, b);
```

```text
<anon>:3:18: 3:22 error: cannot borrow immutable indexed content `x[..]` as mutable
<anon>:3 let a = &mut x[0];
^~~~
<anon>:4:18: 4:22 error: cannot borrow immutable indexed content `x[..]` as mutable
<anon>:4 let b = &mut x[1];
^~~~
<anon>:4:14: 4:18 error: cannot borrow `x[..]` as mutable more than once at a time
<anon>:4 let b = &mut x[1];
^~~~
<anon>:3:14: 3:18 note: previous borrow of `x[..]` occurs here; the mutable borrow prevents subsequent moves, borrows, or modification of `x[..]` until the borrow ends
<anon>:3 let a = &mut x[0];
^~~~
<anon>:6:2: 6:2 note: previous borrow ends here
<anon>:1 fn main() {
<anon>:2 let mut x = [1, 2, 3];
<anon>:3 let a = &mut x[0];
<anon>:4 let b = &mut x[1];
<anon>:5 println!("{} {}", a, b);
<anon>:6 }
^
error: aborting due to 2 previous errors
```

Expand Down

0 comments on commit 6a86a0c

Please sign in to comment.