]> Repositorios git - scryer-prolog.git/commitdiff
Issue 3264 add rationale comment & `#[allow(...)]`
authorAlexander McLin <[email protected]>
Tue, 14 Apr 2026 19:27:52 +0000 (15:27 -0400)
committerAlexander McLin <[email protected]>
Mon, 25 May 2026 22:13:02 +0000 (18:13 -0400)
Explain why no multibyte UTF-8 encoding support
Disable `bytes()` clippy warning about performance penalty due to unbuffered bytes

src/read/fallback_mode.rs

index 759ac890cb33009d56eb5d451fc6dcdb3cef53db..1123a2b28213ae4ef9cf96e80ec928391cd42216 100644 (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
 // byte to KeyEvent char if it falls within the ASCII subset of UTF-8.
-//
 // 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> {
+    #[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();
 
     match byte_or_none {