Re:Thoughts on Rust, a few thousand lines in
by estebank on Wednesday January 09, 2019 @07:43PM
(#18870538)
One nitpick: `.chars`[1] gives you an iterable[2] of `char`s[3], each of which is always a 4 byte representation of a valid unicode character. This means that `"asdf".chars().collect()` will have a different size to `"asdf"` and `"asdf".chars().as_str()`. `.chars()` will never give you an incomplete codepoint, but it will give you incomplete characters, as you could have many c̶̼̟̏ó̷̘̉n̴̖̞̏̇t̸̡̃ĭ̸̻̬n̴̯͉̂͑ṵ̴̑a̷̛̫̳ẗ̸͕́i̷̱̫̓̋ǫ̸̑ǹ̶̼̅s̸̩̾̌ to represent what visually are a single char.
[1]: https://doc.rust-lang.org/std/string/struct.String.html#meth...
Re:Thoughts on Rust, a few thousand lines in
by moosingin3space on Wednesday January 09, 2019 @07:58PM
(#18870610)
> visually are a single char
IIRC that's what grapheme clusters are for.
Basically, string indexing is a lot harder than it seems at first glance, depending on what you want.