mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-02-02 23:38:41 +08:00
17 lines
675 B
Plaintext
17 lines
675 B
Plaintext
$ cargo run
|
|
Compiling ownership v0.1.0 (file:///projects/ownership)
|
|
error[E0596]: cannot borrow `*some_string` as mutable, as it is behind a `&` reference
|
|
--> src/main.rs:8:5
|
|
|
|
|
7 | fn change(some_string: &String) {
|
|
| ------- help: consider changing this to be a mutable reference: `&mut String`
|
|
8 | some_string.push_str(", world");
|
|
| ^^^^^^^^^^^ `some_string` is a `&` reference, so the data it refers to cannot be borrowed as mutable
|
|
|
|
error: aborting due to previous error
|
|
|
|
For more information about this error, try `rustc --explain E0596`.
|
|
error: could not compile `ownership`
|
|
|
|
To learn more, run the command again with --verbose.
|