Why does Rust have String and str? What are the differences between String and str? When does one use String
String
str
str, only used as &str, is a string slice, a reference to a UTF-8 byte array.
&str
String is what used to be ~str, a growable, owned UTF-8 byte array.
~str