A str in rust is an utf8 string, to quote the docs ‘String slices are always valid utf8’. But using get or [] on a str might yield invalid utf8 and panic the program because they use byte indexes not char indexes. WTF @rustlang ?!?
-
-
Replying to @frustlang @rustlang
Its because [] indexes in "char"s (bytes), and a single byte of a UTF-8 string might not be a valid Unicode characters. For instance, "é" is two bytes in UTF-8, but each individual bytes are not valid characters.
1 reply 0 retweets 0 likes
Replying to @HugoLaloge @frustlang
To be clear, a rust char is not a byte (I’m assuming that’s why you used “, but just want to make it explicit!)
8:55 AM - 1 Jul 2019
0 replies
0 retweets
1 like
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.