#Does String::from("some string here"); clone the bytes of the supplied literal to a heap alloc?
3 messages · Page 1 of 1 (latest)
https://doc.rust-lang.org/std/string/struct.String.html#impl-From<%26str>-for-String
That blurb says that "the result is allocated on the heap". So, it's an eager byte copy.
A UTF-8–encoded, growable string.
Yeah, whatever character data the &str is referencing could be dropped before the String grows, and then it can't copy over the bytes, so it does it right away.