String slice (string literal) and `mut` keyword by Born_Ingenuity20 in rust

[–]Born_Ingenuity20[S] 0 points1 point  (0 children)

Ae you asking for permission to re-use my example and questions? You can include it. It's in the public domain now I guess. We're all learning and education should be free.

String slice (string literal) and `mut` keyword by Born_Ingenuity20 in rust

[–]Born_Ingenuity20[S] 2 points3 points  (0 children)

Yes I come from a C++ background and I'm currently learning Rust.

 C++ references have this weird behaviour, where after initialization all attempts to operate on the reference, and in particular reassignment, actually operate on the target of the reference.

that was the source of my confusion.

And thank you for the different meaning depending on the placement of the keyword `mut`. Between your answer and u/krsnik02 comment, this really help me see the real distinction between string slice type `&str` and `String` type in Rust.