From 272f5c05dc4399389c011d8693bae073523aebfb Mon Sep 17 00:00:00 2001 From: Josh McKinney Date: Wed, 25 Jun 2025 00:38:41 -0700 Subject: [PATCH] chore: fix new lints (#1922) --- examples/apps/gauge/src/main.rs | 2 +- examples/apps/weather/src/main.rs | 4 ++-- ratatui-core/src/buffer/buffer.rs | 2 +- ratatui-core/src/terminal/terminal.rs | 6 +++--- ratatui-core/src/text/line.rs | 4 ++-- ratatui-core/src/text/text.rs | 6 +++--- ratatui-widgets/src/block.rs | 2 +- ratatui-widgets/src/calendar.rs | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/apps/gauge/src/main.rs b/examples/apps/gauge/src/main.rs index 3f97622f..9310aca0 100644 --- a/examples/apps/gauge/src/main.rs +++ b/examples/apps/gauge/src/main.rs @@ -185,7 +185,7 @@ impl App { } } -fn title_block(title: &str) -> Block { +fn title_block(title: &str) -> Block<'_> { let title = Line::from(title).centered(); Block::new() .borders(Borders::NONE) diff --git a/examples/apps/weather/src/main.rs b/examples/apps/weather/src/main.rs index 185a6097..688dd990 100644 --- a/examples/apps/weather/src/main.rs +++ b/examples/apps/weather/src/main.rs @@ -69,7 +69,7 @@ impl App { } /// Create a vertical bar chart from the temperatures data. -fn vertical_barchart(temperatures: &[u8]) -> BarChart { +fn vertical_barchart(temperatures: &[u8]) -> BarChart<'_> { let bars: Vec = temperatures .iter() .enumerate() @@ -80,7 +80,7 @@ fn vertical_barchart(temperatures: &[u8]) -> BarChart { .bar_width(5) } -fn vertical_bar(hour: usize, temperature: &u8) -> Bar { +fn vertical_bar(hour: usize, temperature: &u8) -> Bar<'_> { Bar::default() .value(u64::from(*temperature)) .label(Line::from(format!("{hour:>02}:00"))) diff --git a/ratatui-core/src/buffer/buffer.rs b/ratatui-core/src/buffer/buffer.rs index b31d8871..5c84fa0f 100644 --- a/ratatui-core/src/buffer/buffer.rs +++ b/ratatui-core/src/buffer/buffer.rs @@ -1237,7 +1237,7 @@ mod tests { } /// Emojis normally contain various characters which should stay part of the Emoji. - /// This should work fine by utilizing unicode_segmentation but a testcase is probably helpful + /// This should work fine by utilizing `unicode_segmentation` but a testcase is probably helpful /// due to the nature of never perfect Unicode implementations and all of its quirks. #[rstest] // Shrug without gender or skintone. Has a width of 2 like all emojis have. diff --git a/ratatui-core/src/terminal/terminal.rs b/ratatui-core/src/terminal/terminal.rs index e882e470..39c93994 100644 --- a/ratatui-core/src/terminal/terminal.rs +++ b/ratatui-core/src/terminal/terminal.rs @@ -166,7 +166,7 @@ where } /// Get a Frame object which provides a consistent view into the terminal state for rendering. - pub const fn get_frame(&mut self) -> Frame { + pub const fn get_frame(&mut self) -> Frame<'_> { let count = self.frame_count; Frame { cursor_position: None, @@ -299,7 +299,7 @@ where /// } /// # std::io::Result::Ok(()) /// ``` - pub fn draw(&mut self, render_callback: F) -> Result + pub fn draw(&mut self, render_callback: F) -> Result, B::Error> where F: FnOnce(&mut Frame), { @@ -374,7 +374,7 @@ where /// } /// # io::Result::Ok(()) /// ``` - pub fn try_draw(&mut self, render_callback: F) -> Result + pub fn try_draw(&mut self, render_callback: F) -> Result, B::Error> where F: FnOnce(&mut Frame) -> Result<(), E>, E: Into, diff --git a/ratatui-core/src/text/line.rs b/ratatui-core/src/text/line.rs index bf8a96d9..0616e7e8 100644 --- a/ratatui-core/src/text/line.rs +++ b/ratatui-core/src/text/line.rs @@ -534,12 +534,12 @@ impl<'a> Line<'a> { } /// Returns an iterator over the spans of this line. - pub fn iter(&self) -> core::slice::Iter> { + pub fn iter(&self) -> core::slice::Iter<'_, Span<'a>> { self.spans.iter() } /// Returns a mutable iterator over the spans of this line. - pub fn iter_mut(&mut self) -> core::slice::IterMut> { + pub fn iter_mut(&mut self) -> core::slice::IterMut<'_, Span<'a>> { self.spans.iter_mut() } diff --git a/ratatui-core/src/text/text.rs b/ratatui-core/src/text/text.rs index f7ee5eef..029545e0 100644 --- a/ratatui-core/src/text/text.rs +++ b/ratatui-core/src/text/text.rs @@ -507,12 +507,12 @@ impl<'a> Text<'a> { } /// Returns an iterator over the lines of the text. - pub fn iter(&self) -> core::slice::Iter> { + pub fn iter(&self) -> core::slice::Iter<'_, Line<'a>> { self.lines.iter() } /// Returns an iterator that allows modifying each line. - pub fn iter_mut(&mut self) -> core::slice::IterMut> { + pub fn iter_mut(&mut self) -> core::slice::IterMut<'_, Line<'a>> { self.lines.iter_mut() } @@ -699,7 +699,7 @@ pub trait ToText { /// error. This indicates an incorrect `Display` implementation since `fmt::Write for String` never /// returns an error itself. impl ToText for T { - fn to_text(&self) -> Text { + fn to_text(&self) -> Text<'_> { Text::raw(self.to_string()) } } diff --git a/ratatui-widgets/src/block.rs b/ratatui-widgets/src/block.rs index bc69f4ec..1b09b3ee 100644 --- a/ratatui-widgets/src/block.rs +++ b/ratatui-widgets/src/block.rs @@ -879,7 +879,7 @@ impl Block<'_> { &self, position: Position, alignment: Alignment, - ) -> impl DoubleEndedIterator { + ) -> impl DoubleEndedIterator> { self.titles .iter() .filter(move |(pos, _)| pos.unwrap_or(self.titles_position) == position) diff --git a/ratatui-widgets/src/calendar.rs b/ratatui-widgets/src/calendar.rs index ef9f2493..8e9bb2e7 100644 --- a/ratatui-widgets/src/calendar.rs +++ b/ratatui-widgets/src/calendar.rs @@ -113,7 +113,7 @@ impl<'a, DS: DateStyler> Monthly<'a, DS> { } /// All logic to style a date goes here. - fn format_date(&self, date: Date) -> Span { + fn format_date(&self, date: Date) -> Span<'_> { if date.month() == self.display_date.month() { Span::styled( format!("{:2?}", date.day()),