diff options
-rw-r--r-- | src/blocking/input.rs | 3 | ||||
-rw-r--r-- | src/input.rs | 3 |
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(); |