Issue 3264 add rationale comment & #[allow(...)]

Explain why no multibyte UTF-8 encoding support
Disable `bytes()` clippy warning about performance penalty due to unbuffered bytes
This commit is contained in:
Alexander McLin
2026-04-14 15:27:52 -04:00
parent 257209df75
commit b6db1cde25

View File

@@ -6,9 +6,19 @@ use std::io::{Error, ErrorKind, Read};
// //
// Retrieve a single byte from stdin, does not support full Unicode decoding; only convert // Retrieve a single byte from stdin, does not support full Unicode decoding; only convert
// byte to KeyEvent char if it falls within the ASCII subset of UTF-8. // byte to KeyEvent char if it falls within the ASCII subset of UTF-8.
//
// Does not support passing through Ctrl-C as a KeyEvent. // Does not support passing through Ctrl-C as a KeyEvent.
//
// We are not supporting multibyte UTF-8 encodings because we are only
// interested in single ASCII characters which are 1-byte UTF-8 characters.
// Multibyte non-ASCII characters would be ignored anyway, so it's not worth the effort.
//
// It is expected that `limited_support_read` will only be used when prompting for user
// input during solution enumeration and the available commands are single ASCII characters.
pub(crate) fn limited_support_read() -> std::io::Result<KeyEvent> { pub(crate) fn limited_support_read() -> std::io::Result<KeyEvent> {
#[allow(
clippy::unbuffered_bytes,
reason = "We are aware of `bytes()` performance pitfall but don't expect it to be relevant here, we are doing single byte user input I/O."
)]
let byte_or_none = std::io::stdin().bytes().next(); let byte_or_none = std::io::stdin().bytes().next();
match byte_or_none { match byte_or_none {