&str is copyable but also a reference; hence, c_str, although copied, still references str_literal. But what about b_str? It is also a reference to the same slice, yet modifying b_str does not affect str_literal or c_str. Is there a specific concept that explains this behavior?
you only modified the reference (i.e. pointers), not the underlying string data.
strings in rust are immutable, you cannot mutate strings in place, you must convert it to bytes to make changes, but convertion the modified bytes back to string needs to be validated for utf8 encoding.
You aren’t even modifying the referenceb_str; you’re introducing a completely new variable that just happens to shadow the existing variable of the same name.
This is essentially the same as
let b_str: &str = &*str_literal;
let c_str : &str = str_literal;
let foo_bar = "xyz";