From 446ce3d134a7e5e6158ecbd4ceb24e3c13abde61 Mon Sep 17 00:00:00 2001 From: Mikael Mello Date: Sun, 29 Sep 2024 16:46:20 -0700 Subject: [PATCH] Fix lint warnings --- inquire/src/ansi.rs | 1 + inquire/src/date_utils.rs | 12 ++++++------ inquire/src/prompts/one_liners.rs | 28 ++++++++++++++-------------- inquire/src/terminal/crossterm.rs | 2 +- inquire/src/terminal/mod.rs | 1 + inquire/src/terminal/termion.rs | 4 ++-- 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/inquire/src/ansi.rs b/inquire/src/ansi.rs index 4b651c6e..b6adde5a 100644 --- a/inquire/src/ansi.rs +++ b/inquire/src/ansi.rs @@ -165,6 +165,7 @@ impl<'a> Iterator for AnsiStrippedChars<'a> { /// Constructs an iterator over the chars of the input string, stripping away ANSI escape codes. pub trait AnsiStrippable { + #[allow(unused)] fn ansi_stripped_chars(&self) -> AnsiStrippedChars<'_>; } diff --git a/inquire/src/date_utils.rs b/inquire/src/date_utils.rs index cc348f46..5936eff7 100644 --- a/inquire/src/date_utils.rs +++ b/inquire/src/date_utils.rs @@ -7,7 +7,7 @@ pub fn get_current_date() -> NaiveDate { } pub fn get_start_date(month: chrono::Month, year: i32) -> NaiveDate { - chrono::NaiveDate::from_ymd_opt(year, month.number_from_month(), 1).unwrap() + NaiveDate::from_ymd_opt(year, month.number_from_month(), 1).unwrap() } pub fn get_month(month: u32) -> chrono::Month { @@ -43,23 +43,23 @@ mod tests { fn test_get_start_date() { assert_eq!( get_start_date(chrono::Month::January, 2021), - chrono::NaiveDate::from_ymd_opt(2021, 1, 1).unwrap() + NaiveDate::from_ymd_opt(2021, 1, 1).unwrap() ); assert_eq!( get_start_date(chrono::Month::February, 2021), - chrono::NaiveDate::from_ymd_opt(2021, 2, 1).unwrap() + NaiveDate::from_ymd_opt(2021, 2, 1).unwrap() ); assert_eq!( get_start_date(chrono::Month::March, 2021), - chrono::NaiveDate::from_ymd_opt(2021, 3, 1).unwrap() + NaiveDate::from_ymd_opt(2021, 3, 1).unwrap() ); assert_eq!( get_start_date(chrono::Month::December, 1883), - chrono::NaiveDate::from_ymd_opt(1883, 12, 1).unwrap() + NaiveDate::from_ymd_opt(1883, 12, 1).unwrap() ); assert_eq!( get_start_date(chrono::Month::June, 3042), - chrono::NaiveDate::from_ymd_opt(3042, 6, 1).unwrap() + NaiveDate::from_ymd_opt(3042, 6, 1).unwrap() ); } diff --git a/inquire/src/prompts/one_liners.rs b/inquire/src/prompts/one_liners.rs index d6d76bdc..ed715609 100644 --- a/inquire/src/prompts/one_liners.rs +++ b/inquire/src/prompts/one_liners.rs @@ -122,8 +122,8 @@ where /// # Returns /// /// * `InquireResult`: An enum that represents the result of the prompt operation. If the operation is successful, -/// it returns `InquireResult::Ok(NaiveDate)` where NaiveDate's value is the date selected by the user. If the operation -/// encounters an error, it returns `InquireResult::Err(InquireError)`. +/// it returns `InquireResult::Ok(NaiveDate)` where NaiveDate's value is the date selected by the user. If the operation +/// encounters an error, it returns `InquireResult::Err(InquireError)`. /// /// # Example /// @@ -158,8 +158,8 @@ where /// # Returns /// /// * `InquireResult`: An enum that represents the result of the prompt operation. If the operation is successful, -/// it returns `InquireResult::Ok(f64)` where f64 is the number parsed from the user's input. If the operation -/// encounters an error, it returns `InquireResult::Err(InquireError)`. +/// it returns `InquireResult::Ok(f64)` where f64 is the number parsed from the user's input. If the operation +/// encounters an error, it returns `InquireResult::Err(InquireError)`. /// /// # Example /// @@ -193,8 +193,8 @@ where /// # Returns /// /// * `InquireResult`: An enum that represents the result of the prompt operation. If the operation is successful, -/// it returns `InquireResult::Ok(f32)` where f32 is the number parsed from the user's input. If the operation -/// encounters an error, it returns `InquireResult::Err(InquireError)`. +/// it returns `InquireResult::Ok(f32)` where f32 is the number parsed from the user's input. If the operation +/// encounters an error, it returns `InquireResult::Err(InquireError)`. /// /// # Example /// @@ -228,8 +228,8 @@ where /// # Returns /// /// * `InquireResult`: An enum that represents the result of the prompt operation. If the operation is successful, -/// it returns `InquireResult::Ok(u64)` where u64 is the number parsed from the user's input. If the operation -/// encounters an error, it returns `InquireResult::Err(InquireError)`. +/// it returns `InquireResult::Ok(u64)` where u64 is the number parsed from the user's input. If the operation +/// encounters an error, it returns `InquireResult::Err(InquireError)`. /// /// # Example /// @@ -263,8 +263,8 @@ where /// # Returns /// /// * `InquireResult`: An enum that represents the result of the prompt operation. If the operation is successful, -/// it returns `InquireResult::Ok(u32)` where u32 is the number parsed from the user's input. If the operation -/// encounters an error, it returns `InquireResult::Err(InquireError)`. +/// it returns `InquireResult::Ok(u32)` where u32 is the number parsed from the user's input. If the operation +/// encounters an error, it returns `InquireResult::Err(InquireError)`. /// /// # Example /// @@ -298,8 +298,8 @@ where /// # Returns /// /// * `InquireResult`: An enum that represents the result of the prompt operation. If the operation is successful, -/// it returns `InquireResult::Ok(usize)` where usize is the number parsed from the user's input. If the operation -/// encounters an error, it returns `InquireResult::Err(InquireError)`. +/// it returns `InquireResult::Ok(usize)` where usize is the number parsed from the user's input. If the operation +/// encounters an error, it returns `InquireResult::Err(InquireError)`. /// /// # Example /// @@ -333,8 +333,8 @@ where /// # Returns /// /// * `InquireResult`: An enum that represents the result of the prompt operation. If the operation is successful, -/// it returns `InquireResult::Ok(u128)` where u128 is the number parsed from the user's input. If the operation -/// encounters an error, it returns `InquireResult::Err(InquireError)`. +/// it returns `InquireResult::Ok(u128)` where u128 is the number parsed from the user's input. If the operation +/// encounters an error, it returns `InquireResult::Err(InquireError)`. /// /// # Example /// diff --git a/inquire/src/terminal/crossterm.rs b/inquire/src/terminal/crossterm.rs index 3d0a9cdc..3e781b55 100644 --- a/inquire/src/terminal/crossterm.rs +++ b/inquire/src/terminal/crossterm.rs @@ -46,7 +46,7 @@ impl InputReader for CrosstermKeyReader { impl CrosstermTerminal { pub fn new() -> InquireResult { - crossterm::terminal::enable_raw_mode()?; + terminal::enable_raw_mode()?; Ok(Self { io: IO::Std(stderr()), diff --git a/inquire/src/terminal/mod.rs b/inquire/src/terminal/mod.rs index 0cbf379a..846ec120 100644 --- a/inquire/src/terminal/mod.rs +++ b/inquire/src/terminal/mod.rs @@ -37,6 +37,7 @@ pub trait Terminal: Sized { fn cursor_down(&mut self, cnt: u16) -> Result<()>; fn cursor_left(&mut self, cnt: u16) -> Result<()>; fn cursor_right(&mut self, cnt: u16) -> Result<()>; + #[allow(unused)] fn cursor_move_to_column(&mut self, idx: u16) -> Result<()>; fn flush(&mut self) -> Result<()>; diff --git a/inquire/src/terminal/termion.rs b/inquire/src/terminal/termion.rs index 6fcd6464..4eb5cc52 100644 --- a/inquire/src/terminal/termion.rs +++ b/inquire/src/terminal/termion.rs @@ -196,11 +196,11 @@ impl<'a> Terminal for TermionTerminal<'a> { } fn cursor_hide(&mut self) -> Result<()> { - write!(self.get_writer(), "{}", termion::cursor::Hide) + write!(self.get_writer(), "{}", cursor::Hide) } fn cursor_show(&mut self) -> Result<()> { - write!(self.get_writer(), "{}", termion::cursor::Show) + write!(self.get_writer(), "{}", cursor::Show) } }