4 ms·
Thanks for the clarification. What's the idiomatic way to read one character from stdin?
by rogual 11y ago
Thanks for the clarification. What's the idiomatic way to read one character from stdin?
- masklinn 11y agoThe `bytes()` iterator is stable and provides a stream of u8 (well io::Result<u8>) which is sufficient for what you want. I don't think there's a good way to decode an iterator of bytes (which bytes isn't either way, but it could be adapted) to a chars iterator at the moment.
- rogual 11y agoThank you. Bytes will do just fine. I'm glad Rust is pedantic about bytes vs. chars.
- steveklabnik 11y agoTo elaborate slightly further, char in Rust is four bytes, as it represents a Unicode Scalar Value. So the chars iterator isn't yet stable because it's not clear what should be done in the case of a read of a partial char. This is, of course, fixable, there's just a lot to do, and that's the question for this specific API.