4 ms·
> Rust UCS4 (last time I checked) Rust chars are 32bit Unicode codepoints. But strings themselves are utf-8. That is the string type, ~str, is basically just ~
by pitterpatter 13y ago
> Rust UCS4 (last time I checked)
Rust chars are 32bit Unicode codepoints. But strings themselves are utf-8. That is the string type, ~str, is basically just ~[u8], a vector of bytes and not ~[char].
`.len()` [O(1)] gives you byte length while `.char_len()` [O(n)] gives you the number of codepoints.
So strings in rust are just vectors of bytes with the invariant that it's valid utf-8.
- berdario 13y agoThanks, I didn't know that