4 ms·
It's also easier to get away with Rust's decision to say no, strings aren't sequences of code points (which they aren't) if you do all the work to support ASCII
by tialaramex 4y ago
It's also easier to get away with Rust's decision to say no, strings aren't sequences of code points (which they aren't) if you do all the work to support ASCII on bytes anyway.
Rust defines things like is_ascii_hexdigit() on both char (a Unicode scalar) and u8 (a byte) and so if you're writing some low-level code which cares only about bytes you aren't expected to either turn them into a string to find out if the byte you're looking at is an ASCII digit or improvise something.
This sort of thing means the programmer who is moving bytes and is very angry about the notion of character encoding needn't touch Rust's Unicode stuff, while the programmer who is responsible for text rendering isn't given a bunch of undifferentiated bytes and told "Good luck". Somebody needs to figure out what the encoding is, but likely that programmer actually cares about the difference between ISO-8859-1 and Windows code page 1252 or at least is aware that somebody else might care.