4 ms·
String is the heap-allocated sequence of characters, str is a view into a String. Strings in Rust are guaranteed to be valid UTF-8; file paths in Windows are n
by gnuvince 11y ago
String is the heap-allocated sequence of characters, str is a view into a String. Strings in Rust are guaranteed to be valid UTF-8; file paths in Windows are not, so you cannot use String for those, so you need another type. Repeat for different "stringy" types that do not have the same semantics as Strings and you end up with a number of string types.
- steveklabnik 11y ago> String is the heap-allocated sequence of characters, To be clear, String is a heap-allocated sequence of u8 which form valid unicode scalar values. "character" in Rust usually means "char", and String is _not_ a list of chars.