2 ms·
For strings, I believe Rust's approach of a dynamic `String` and a view `str` is the right approach. For a minimal std, maybe Zig can have a standard `str` typ
by Lvl999Noob 5y ago
For strings, I believe Rust's approach of a dynamic `String` and a view `str` is the right approach.
For a minimal std, maybe Zig can have a standard `str` type which is used for all functions that don't need to grow the string and the `String` type is provided by any 3rd party library which is expected to provide a conversion function from `String` to `str`.
These strings types could or could not have a requirement of being Utf-8. Maybe there is a builtin wrapper to convert them. So you can any dynamic byte array which can be converted to `str` (just a pointer and length, no validation) which can be later converted to `utf8` (str but validated). A `String` which guarantees Utf-8 could directly convert to `utf8` to save validation costs.