From bb068892c93713befbc8dab04577cbc2a59cedec Mon Sep 17 00:00:00 2001 From: Josh McKinney Date: Tue, 15 Apr 2025 11:09:05 -0700 Subject: [PATCH] chore: fix io_other_error clippy lints (#1756) Pre-emptive fix for new lint to be added in 1.87 (currently in beta). https://rust-lang.github.io/rust-clippy/master/index.html\#io_other_error --- ratatui-core/src/backend.rs | 7 +++---- ratatui-crossterm/src/lib.rs | 2 +- ratatui-termwiz/src/lib.rs | 6 ++---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ratatui-core/src/backend.rs b/ratatui-core/src/backend.rs index 403e50f1..0f90ed01 100644 --- a/ratatui-core/src/backend.rs +++ b/ratatui-core/src/backend.rs @@ -279,10 +279,9 @@ pub trait Backend { ClearType::AfterCursor | ClearType::BeforeCursor | ClearType::CurrentLine - | ClearType::UntilNewLine => Err(io::Error::new( - io::ErrorKind::Other, - format!("clear_type [{clear_type:?}] not supported with this backend"), - )), + | ClearType::UntilNewLine => Err(io::Error::other(format!( + "clear_type [{clear_type:?}] not supported with this backend" + ))), } } diff --git a/ratatui-crossterm/src/lib.rs b/ratatui-crossterm/src/lib.rs index 5793e198..e68de9cb 100644 --- a/ratatui-crossterm/src/lib.rs +++ b/ratatui-crossterm/src/lib.rs @@ -230,7 +230,7 @@ where fn get_cursor_position(&mut self) -> io::Result { crossterm::cursor::position() .map(|(x, y)| Position { x, y }) - .map_err(|e| io::Error::new(io::ErrorKind::Other, e.to_string())) + .map_err(io::Error::other) } fn set_cursor_position>(&mut self, position: P) -> io::Result<()> { diff --git a/ratatui-termwiz/src/lib.rs b/ratatui-termwiz/src/lib.rs index f5b1d2f9..30240fef 100644 --- a/ratatui-termwiz/src/lib.rs +++ b/ratatui-termwiz/src/lib.rs @@ -237,7 +237,7 @@ impl Backend for TermwizBackend { .buffered_terminal .terminal() .get_screen_size() - .map_err(|e| io::Error::new(io::ErrorKind::Other, e))?; + .map_err(io::Error::other)?; Ok(WindowSize { columns_rows: Size { width: u16_max(cols), @@ -251,9 +251,7 @@ impl Backend for TermwizBackend { } fn flush(&mut self) -> io::Result<()> { - self.buffered_terminal - .flush() - .map_err(|e| io::Error::new(io::ErrorKind::Other, e))?; + self.buffered_terminal.flush().map_err(io::Error::other)?; Ok(()) }