From 5997dd043695a2354d4854cd2dcdb7a8cfd0e879 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 8 Mar 2023 13:02:19 -0500 Subject: clippy --- src/blocking/input.rs | 2 -- src/blocking/output.rs | 2 -- src/error.rs | 6 +++--- src/key.rs | 46 +++++++++++++++++++++++----------------------- src/output.rs | 2 -- src/private.rs | 2 +- 6 files changed, 27 insertions(+), 33 deletions(-) diff --git a/src/blocking/input.rs b/src/blocking/input.rs index 63c9ac5..e41e8f1 100644 --- a/src/blocking/input.rs +++ b/src/blocking/input.rs @@ -54,8 +54,6 @@ impl RawGuard { impl Drop for RawGuard { /// Calls `cleanup`. fn drop(&mut self) { - // https://github.com/rust-lang/rust-clippy/issues/8003 - #[allow(clippy::let_underscore_drop)] let _ = self.cleanup(); } } diff --git a/src/blocking/output.rs b/src/blocking/output.rs index 8d21c41..482a895 100644 --- a/src/blocking/output.rs +++ b/src/blocking/output.rs @@ -36,8 +36,6 @@ impl ScreenGuard { impl Drop for ScreenGuard { /// Calls `cleanup`. fn drop(&mut self) { - // https://github.com/rust-lang/rust-clippy/issues/8003 - #[allow(clippy::let_underscore_drop)] let _ = self.cleanup(); } } diff --git a/src/error.rs b/src/error.rs index fea92b6..8b99337 100644 --- a/src/error.rs +++ b/src/error.rs @@ -15,13 +15,13 @@ impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::ReadStdin(e) => { - write!(f, "error reading from stdin: {}", e) + write!(f, "error reading from stdin: {e}") } Self::SetTerminalMode(e) => { - write!(f, "error setting terminal mode: {}", e) + write!(f, "error setting terminal mode: {e}") } Self::WriteStdout(e) => { - write!(f, "error writing to stdout: {}", e) + write!(f, "error writing to stdout: {e}") } } } diff --git a/src/key.rs b/src/key.rs index 15c0303..ea0568d 100644 --- a/src/key.rs +++ b/src/key.rs @@ -35,29 +35,29 @@ impl Key { #[must_use] pub fn into_bytes(self) -> Vec { match self { - Key::String(s) => s.into_bytes(), - Key::Char(c) => c.to_string().into_bytes(), - Key::Bytes(s) => s, - Key::Byte(c) => vec![c], - Key::Ctrl(c) => vec![c - b'a' + 1], - Key::Meta(c) => vec![b'\x1b', c], - Key::Backspace => b"\x7f".to_vec(), - Key::Escape => b"\x1b".to_vec(), - Key::Up => b"\x1b[A".to_vec(), - Key::Down => b"\x1b[B".to_vec(), - Key::Right => b"\x1b[C".to_vec(), - Key::Left => b"\x1b[D".to_vec(), - Key::KeypadUp => b"\x1bOA".to_vec(), - Key::KeypadDown => b"\x1bOB".to_vec(), - Key::KeypadRight => b"\x1bOC".to_vec(), - Key::KeypadLeft => b"\x1bOD".to_vec(), - Key::Home => b"\x1b[H".to_vec(), - Key::End => b"\x1b[F".to_vec(), - Key::Insert => b"\x1b[2~".to_vec(), - Key::Delete => b"\x1b[3~".to_vec(), - Key::PageUp => b"\x1b[5~".to_vec(), - Key::PageDown => b"\x1b[6~".to_vec(), - Key::F(c) => match c { + Self::String(s) => s.into_bytes(), + Self::Char(c) => c.to_string().into_bytes(), + Self::Bytes(s) => s, + Self::Byte(c) => vec![c], + Self::Ctrl(c) => vec![c - b'a' + 1], + Self::Meta(c) => vec![b'\x1b', c], + Self::Backspace => b"\x7f".to_vec(), + Self::Escape => b"\x1b".to_vec(), + Self::Up => b"\x1b[A".to_vec(), + Self::Down => b"\x1b[B".to_vec(), + Self::Right => b"\x1b[C".to_vec(), + Self::Left => b"\x1b[D".to_vec(), + Self::KeypadUp => b"\x1bOA".to_vec(), + Self::KeypadDown => b"\x1bOB".to_vec(), + Self::KeypadRight => b"\x1bOC".to_vec(), + Self::KeypadLeft => b"\x1bOD".to_vec(), + Self::Home => b"\x1b[H".to_vec(), + Self::End => b"\x1b[F".to_vec(), + Self::Insert => b"\x1b[2~".to_vec(), + Self::Delete => b"\x1b[3~".to_vec(), + Self::PageUp => b"\x1b[5~".to_vec(), + Self::PageDown => b"\x1b[6~".to_vec(), + Self::F(c) => match c { 1 => b"\x1bOP".to_vec(), 2 => b"\x1bOQ".to_vec(), 3 => b"\x1bOR".to_vec(), diff --git a/src/output.rs b/src/output.rs index 483de6b..1ac9f43 100644 --- a/src/output.rs +++ b/src/output.rs @@ -49,9 +49,7 @@ impl Drop for ScreenGuard { if !self.cleaned_up { let mut stdout = std::io::stdout(); - #[allow(clippy::let_underscore_drop)] let _ = stdout.write_all(crate::DEINIT); - #[allow(clippy::let_underscore_drop)] let _ = stdout.flush(); } } diff --git a/src/private.rs b/src/private.rs index 87e281c..7de7627 100644 --- a/src/private.rs +++ b/src/private.rs @@ -318,7 +318,7 @@ pub trait Input { } fn getc(&mut self) -> Option { - self.buf().get(0).copied().map(|c| { + self.buf().first().copied().map(|c| { self.consume(1); c }) -- cgit v1.2.3-54-g00ecf