mirror of
https://github.com/ratatui-org/ratatui
synced 2024-11-09 22:54:17 +00:00
fix: clippy lints from rust 1.81.0 (#1356)
This commit is contained in:
parent
68886d1787
commit
da821b431e
4 changed files with 7 additions and 6 deletions
|
@ -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) {
|
||||
|
|
|
@ -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()?;
|
||||
|
|
|
@ -51,7 +51,7 @@ where
|
|||
O: Iterator<Item = (I, Alignment)>,
|
||||
I: Iterator<Item = StyledGrapheme<'a>>,
|
||||
{
|
||||
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<Item = (I, Alignment)>,
|
||||
I: Iterator<Item = StyledGrapheme<'a>>,
|
||||
{
|
||||
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,
|
||||
|
|
|
@ -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"]));
|
||||
|
|
Loading…
Reference in a new issue