diff --git a/src/backend/curses.rs b/src/backend/curses.rs index fd0fb65..60af17c 100644 --- a/src/backend/curses.rs +++ b/src/backend/curses.rs @@ -54,7 +54,7 @@ impl Backend for CursesBackend { for (col, row, cell) in content { // eprintln!("{:?}", cell); if row != last_row || col != last_col + 1 { - self.curses.move_rc(row as i32, col as i32); + self.curses.move_rc(i32::from(row), i32::from(col)); } last_col = col; last_row = row; @@ -111,7 +111,7 @@ impl Backend for CursesBackend { Ok((x as u16, y as u16)) } fn set_cursor(&mut self, x: u16, y: u16) -> io::Result<()> { - self.curses.move_rc(x as i32, y as i32); + self.curses.move_rc(i32::from(x), i32::from(y)); Ok(()) } fn clear(&mut self) -> io::Result<()> { diff --git a/src/backend/rustbox.rs b/src/backend/rustbox.rs index 0c40c80..f50cc1e 100644 --- a/src/backend/rustbox.rs +++ b/src/backend/rustbox.rs @@ -103,7 +103,7 @@ impl Into for Color { Color::Cyan | Color::LightCyan => rustbox::Color::Cyan, Color::White => rustbox::Color::White, Color::Blue | Color::LightBlue => rustbox::Color::Blue, - Color::Indexed(i) => rustbox::Color::Byte(i as u16), + Color::Indexed(i) => rustbox::Color::Byte(u16::from(i)), Color::Rgb(r, g, b) => rustbox::Color::Byte(rgb_to_byte(r, g, b)), } } diff --git a/src/style.rs b/src/style.rs index cf0d7b1..725cf4e 100644 --- a/src/style.rs +++ b/src/style.rs @@ -26,7 +26,7 @@ pub enum Color { impl Color { /// Returns a short code associated with the color, used for debug purpose /// only - pub(crate) fn code(&self) -> &str { + pub(crate) fn code(self) -> &'static str { match self { Color::Reset => "X", Color::Black => "b", @@ -68,7 +68,7 @@ bitflags! { impl Modifier { /// Returns a short code associated with the color, used for debug purpose /// only - pub(crate) fn code(&self) -> String { + pub(crate) fn code(self) -> String { use std::fmt::Write; let mut result = String::new(); diff --git a/src/widgets/list.rs b/src/widgets/list.rs index d6cbd01..cf3992b 100644 --- a/src/widgets/list.rs +++ b/src/widgets/list.rs @@ -1,5 +1,5 @@ -use std::iter; -use std::iter::Iterator; +use std::convert::AsRef; +use std::iter::{self, Iterator}; use unicode_width::UnicodeWidthStr; @@ -166,7 +166,7 @@ impl<'b> SelectableList<'b> { where I: AsRef + 'b, { - self.items = items.iter().map(|i| i.as_ref()).collect::>(); + self.items = items.iter().map(AsRef::as_ref).collect::>(); self }