|
|
|
|
|
by moosingin3space
2716 days ago
|
|
In Rust, you're supposed to use `unicode-segmentation`[1] if you need to split on logical character (grapheme cluster in the Unicode standard). Otherwise, the iterators `.bytes` emits raw bytes, and `.chars` emits UTF-8 codepoints. Basically, string indexing is a lot harder than it seems at first glance, depending on what you want. |
|
[1]: https://doc.rust-lang.org/std/string/struct.String.html#meth...
[2]: https://doc.rust-lang.org/std/str/struct.Chars.html
[3]: https://doc.rust-lang.org/std/primitive.char.html