Literal string in mutable variable



examples/ownership/literal-string-in-mutable-variable/src/main.rs
fn main() {
    let mut name = "Foo";
    let other = name;
    println!("{name}");
    println!("{other}");

    name = "Foo Bar";

    //name.push_str(" Bar");

    println!("{name}");
    println!("{other}");
}

Foo
Foo
Foo Bar
Foo


error[E0599]: no method named `push_str` found for reference `&str` in the current scope
 --> examples/ownership/literal_string_in_mutable_variable.rs:9:10
  |
9 |     name.push_str(" Bar");
  |          ^^^^^^^^ method not found in `&str`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.