From c4831851936c7c7f707b3c8350ba3ffad9647ba8 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 9 Mar 2021 02:57:28 -0500 Subject: comment --- src/blocking/input.rs | 3 +++ src/input.rs | 3 +++ 2 files changed, 6 insertions(+) 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(); -- cgit v1.2.3