diff --git a/examples/demo/app.rs b/examples/demo/app.rs index 4ee6fd88..84a80c4b 100644 --- a/examples/demo/app.rs +++ b/examples/demo/app.rs @@ -122,7 +122,7 @@ pub struct TabsState<'a> { } impl<'a> TabsState<'a> { - pub fn new(titles: Vec<&'a str>) -> Self { + pub const fn new(titles: Vec<&'a str>) -> Self { Self { titles, index: 0 } } pub fn next(&mut self) { diff --git a/src/terminal/terminal.rs b/src/terminal/terminal.rs index 5bc12566..13c8212a 100644 --- a/src/terminal/terminal.rs +++ b/src/terminal/terminal.rs @@ -205,7 +205,6 @@ where /// of the screen. pub fn resize(&mut self, area: Rect) -> io::Result<()> { let next_area = match self.viewport { - Viewport::Fullscreen => area, Viewport::Inline(height) => { let offset_in_previous_viewport = self .last_known_cursor_pos @@ -219,7 +218,7 @@ where )? .0 } - Viewport::Fixed(_) => area, + Viewport::Fixed(_) | Viewport::Fullscreen => area, }; self.set_viewport_area(next_area); self.clear()?; diff --git a/src/widgets/reflow.rs b/src/widgets/reflow.rs index 0e7224eb..856e239f 100644 --- a/src/widgets/reflow.rs +++ b/src/widgets/reflow.rs @@ -51,7 +51,7 @@ where O: Iterator, I: Iterator>, { - pub fn new(lines: O, max_line_width: u16, trim: bool) -> Self { + pub const fn new(lines: O, max_line_width: u16, trim: bool) -> Self { Self { input_lines: lines, max_line_width, @@ -250,7 +250,7 @@ where O: Iterator, I: Iterator>, { - pub fn new(lines: O, max_line_width: u16) -> Self { + pub const fn new(lines: O, max_line_width: u16) -> Self { Self { input_lines: lines, max_line_width, diff --git a/src/widgets/sparkline.rs b/src/widgets/sparkline.rs index 670ca110..760c6357 100644 --- a/src/widgets/sparkline.rs +++ b/src/widgets/sparkline.rs @@ -237,7 +237,7 @@ mod tests { // Helper function to render a sparkline to a buffer with a given width // filled with x symbols to make it easier to assert on the result - fn render(widget: Sparkline, width: u16) -> Buffer { + fn render(widget: Sparkline<'_>, width: u16) -> Buffer { let area = Rect::new(0, 0, width, 1); let mut buffer = Buffer::filled(area, Cell::new("x")); widget.render(area, &mut buffer); @@ -253,6 +253,8 @@ mod tests { #[test] fn it_does_not_panic_if_max_is_set_to_zero() { + // see https://github.com/rust-lang/rust-clippy/issues/13191 + #[allow(clippy::unnecessary_min_or_max)] let widget = Sparkline::default().data(&[0, 1, 2]).max(0); let buffer = render(widget, 6); assert_eq!(buffer, Buffer::with_lines([" xxx"]));