Literal string



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

    //name = "Foo Bar";

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

Foo
Foo
Foo
Foo


error[E0384]: cannot assign twice to immutable variable `name`
 --> examples/ownership/literal_string.rs:7:5
  |
2 |     let name = "Foo";
  |         ----
  |         |
  |         first assignment to `name`
  |         help: consider making this binding mutable: `mut name`
...
7 |     name = "Foo Bar";
  |     ^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable

error: aborting due to previous error

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