mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-01-23 15:40:27 +08:00
21 lines
675 B
Plaintext
21 lines
675 B
Plaintext
$ cargo run
|
|
Compiling collections v0.1.0 (file:///projects/collections)
|
|
error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable
|
|
--> src/main.rs:6:5
|
|
|
|
|
4 | let first = &v[0];
|
|
| - immutable borrow occurs here
|
|
5 |
|
|
6 | v.push(6);
|
|
| ^^^^^^^^^ mutable borrow occurs here
|
|
7 |
|
|
8 | println!("The first element is: {}", first);
|
|
| ----- immutable borrow later used here
|
|
|
|
error: aborting due to previous error
|
|
|
|
For more information about this error, try `rustc --explain E0502`.
|
|
error: could not compile `collections`
|
|
|
|
To learn more, run the command again with --verbose.
|