I am learning Rust by applying code from the Rust Docs (Nightly) Book.
In Chapter 2.11 Strings they explain that the &str Type of (aka String Slices / String Literals) have a fixed size and can NOT be mutated, whereas the String Type (aka In-Memory Strings) can be mutated.
Why then does Rust and Cargo allow me to declare a mutable variable with let mut named stringLiteral of &str Type here without giving a note, error, or warning in the console that this is not allowable?
Furthermore, why does Rust and Cargo allow me to build $ cargo build --verbose and run the app $ ./target/hello_world, which allows me to overwrite the initial value stored in stringLiteral here, but without giving a note, error, or warning in the console that this is not allowable. I have demonstrate that it has in fact been overwritten by printing its new value to the console [here][https://github.com/ltfschoen/RustTest/blob/master/src/main.rs#L139],
I am learning Rust by applying code from the Rust Docs (Nightly) Book.
In Chapter 2.11 Strings they explain that the &str Type of (aka String Slices / String Literals) have a fixed size and can NOT be mutated, whereas the String Type (aka In-Memory Strings) can be mutated.
Why then does Rust and Cargo allow me to declare a mutable variable with
let mutnamedstringLiteralof &str Type here without giving a note, error, or warning in the console that this is not allowable?Furthermore, why does Rust and Cargo allow me to build
$ cargo build --verboseand run the app$ ./target/hello_world, which allows me to overwrite the initial value stored instringLiteralhere, but without giving a note, error, or warning in the console that this is not allowable. I have demonstrate that it has in fact been overwritten by printing its new value to the console [here][https://github.com/ltfschoen/RustTest/blob/master/src/main.rs#L139],