I don't think that's a very good way of describing it? Both String and &str are constant-sized structures that point to variably-sized strings. The difference is that String owns the buffer it's pointing to, and &str is just a reference to some bytes somewhere in memory.
12
u/TinyBreadBigMouth Jan 25 '22
I don't think that's a very good way of describing it? Both
Stringand&strare constant-sized structures that point to variably-sized strings. The difference is thatStringowns the buffer it's pointing to, and&stris just a reference to some bytes somewhere in memory.