aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-03-09 02:57:28 -0500
committerJesse Luehrs <doy@tozt.net>2021-03-09 02:57:28 -0500
commitc4831851936c7c7f707b3c8350ba3ffad9647ba8 (patch)
treee2c9f66aa45a587748d65e48861ff82d392b2806
parent0cf66f816712e8e8adb941fff57823625611370a (diff)
downloadtextmode-c4831851936c7c7f707b3c8350ba3ffad9647ba8.tar.gz
textmode-c4831851936c7c7f707b3c8350ba3ffad9647ba8.zip
comment
-rw-r--r--src/blocking/input.rs3
-rw-r--r--src/input.rs3
2 files changed, 6 insertions, 0 deletions
diff --git a/src/blocking/input.rs b/src/blocking/input.rs
index 18e349a..6b466a2 100644
--- a/src/blocking/input.rs
+++ b/src/blocking/input.rs
@@ -303,6 +303,9 @@ impl Input {
}
match std::string::String::from_utf8(buf) {
+ // unwrap is fine because buf always contains at least the initial
+ // character, and we have already done the parsing to ensure that
+ // it contains a valid utf8 character before getting here
Ok(s) => Ok(Some(crate::Key::Char(s.chars().next().unwrap()))),
Err(e) => {
buf = e.into_bytes();
diff --git a/src/input.rs b/src/input.rs
index bc16568..ee5d28f 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -306,6 +306,9 @@ impl Input {
}
match std::string::String::from_utf8(buf) {
+ // unwrap is fine because buf always contains at least the initial
+ // character, and we have already done the parsing to ensure that
+ // it contains a valid utf8 character before getting here
Ok(s) => Ok(Some(crate::Key::Char(s.chars().next().unwrap()))),
Err(e) => {
buf = e.into_bytes();