On 1 May 2014 18:54, Mikhail Zabaluev <[email protected]> wrote:
> I don't think that so much hidden complexity would be justified in the
> built-in string type. Encoded text is typically dealt with in protocol
> libraries or similar "I/O barriers" where it should be passed through a
> validating decoder. std::str is guaranteed (within the usual safety
> considerations) to hold a valid UTF-8 byte sequence, which can be passed
> without copying to external libraries. For data domains richer than what
> Unicode text can provide, more complex data representations would need to be
> coded explicitly.

I think it's a tremendous value for a programming language to have a
single, easy and flexible string type – that can be trivially used to
implement protocols and perform I/O operations, too.

And importantly, in all the cases that std::str supports (that is,
UTF-8 strings and external libraries that also use UTF-8 strings), the
proposed design does not need additional copying.

If a string is operated on then it will need to be flattened before an
external library can realistically use it, but this is just a form of
laziness.

\malthe
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to