From a9ae211928a9a449c4e37e872ee4ba07d745b05a Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Tue, 26 May 2020 11:31:40 -0700 Subject: [PATCH] Fix clippy lints --- cursive-core/src/event.rs | 6 ++---- cursive/src/backends/blt.rs | 10 +++------- cursive/src/backends/curses/n.rs | 5 +---- cursive/src/backends/curses/pan.rs | 3 +-- cursive/src/backends/puppet/observed.rs | 9 ++++----- cursive/src/backends/termion.rs | 20 +++++++++----------- 6 files changed, 20 insertions(+), 33 deletions(-) diff --git a/cursive-core/src/event.rs b/cursive-core/src/event.rs index c036b76..9212f8b 100644 --- a/cursive-core/src/event.rs +++ b/cursive-core/src/event.rs @@ -69,10 +69,8 @@ impl EventTrigger { T: Any + std::fmt::Debug, { let tag = Box::new(tag); - EventTrigger { - trigger: Box::new(f), - tag: tag, - } + let trigger = Box::new(f); + EventTrigger { trigger, tag } } /// Check if this trigger has the given tag. diff --git a/cursive/src/backends/blt.rs b/cursive/src/backends/blt.rs index 05720ec..5b65883 100644 --- a/cursive/src/backends/blt.rs +++ b/cursive/src/backends/blt.rs @@ -3,13 +3,9 @@ //! Requires the `blt-backend` feature. #![cfg(feature = "bear-lib-terminal")] -use bear_lib_terminal; - -use self::bear_lib_terminal::geometry::Size; -use self::bear_lib_terminal::terminal::{ - self, state, Event as BltEvent, KeyCode, -}; -use self::bear_lib_terminal::Color as BltColor; +use bear_lib_terminal::geometry::Size; +use bear_lib_terminal::terminal::{self, state, Event as BltEvent, KeyCode}; +use bear_lib_terminal::Color as BltColor; use crate::backend; use crate::event::{Event, Key, MouseButton, MouseEvent}; diff --git a/cursive/src/backends/curses/n.rs b/cursive/src/backends/curses/n.rs index 8c5e681..c13b498 100644 --- a/cursive/src/backends/curses/n.rs +++ b/cursive/src/backends/curses/n.rs @@ -1,6 +1,6 @@ //! Ncurses-specific backend. use log::{debug, warn}; -use ncurses; +use ncurses::mmask_t; use std::cell::{Cell, RefCell}; use std::ffi::CString; @@ -8,8 +8,6 @@ use std::fs::File; use std::io; use std::io::Write; -use libc; - use crate::backend; use crate::event::{Event, Key, MouseButton, MouseEvent}; use crate::theme::{Color, ColorPair, Effect}; @@ -17,7 +15,6 @@ use crate::utf8; use crate::Vec2; use self::super::split_i32; -use self::ncurses::mmask_t; // Use AHash instead of the slower SipHash type HashMap = std::collections::HashMap; diff --git a/cursive/src/backends/curses/pan.rs b/cursive/src/backends/curses/pan.rs index d9e2417..5d80d1d 100644 --- a/cursive/src/backends/curses/pan.rs +++ b/cursive/src/backends/curses/pan.rs @@ -1,6 +1,5 @@ //! Pancuses-specific backend. use log::{debug, warn}; -use pancurses; use std::cell::{Cell, RefCell}; use std::io::{stdout, Write}; @@ -10,8 +9,8 @@ use crate::event::{Event, Key, MouseButton, MouseEvent}; use crate::theme::{Color, ColorPair, Effect}; use crate::Vec2; -use self::pancurses::mmask_t; use super::split_i32; +use pancurses::mmask_t; // Use AHash instead of the slower SipHash type HashMap = std::collections::HashMap; diff --git a/cursive/src/backends/puppet/observed.rs b/cursive/src/backends/puppet/observed.rs index 11826ff..d70a8cb 100644 --- a/cursive/src/backends/puppet/observed.rs +++ b/cursive/src/backends/puppet/observed.rs @@ -95,13 +95,13 @@ pub struct ObservedScreen { impl Display for ObservedScreen { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - write!(f, "captured piece:\n")?; + writeln!(f, "captured piece:")?; write!(f, "x")?; for x in 0..self.size().x { write!(f, "{}", x % 10)?; } - write!(f, "x\n")?; + writeln!(f, "x")?; for y in 0..self.size().y { write!(f, "{}", y % 10)?; @@ -127,15 +127,14 @@ impl Display for ObservedScreen { write!(f, ".")?; } } - write!(f, "|")?; - write!(f, "\n")?; + writeln!(f, "|")?; } write!(f, "x")?; for _x in 0..self.size().x { write!(f, "-")?; } - write!(f, "x\n")?; + writeln!(f, "x")?; Ok(()) } } diff --git a/cursive/src/backends/termion.rs b/cursive/src/backends/termion.rs index a72f2ec..9805af7 100644 --- a/cursive/src/backends/termion.rs +++ b/cursive/src/backends/termion.rs @@ -3,18 +3,16 @@ //! Requires the `termion-backend` feature. #![cfg(feature = "termion")] -use termion; - -use self::termion::color as tcolor; -use self::termion::event::Event as TEvent; -use self::termion::event::Key as TKey; -use self::termion::event::MouseButton as TMouseButton; -use self::termion::event::MouseEvent as TMouseEvent; -use self::termion::input::{MouseTerminal, TermRead}; -use self::termion::raw::{IntoRawMode, RawTerminal}; -use self::termion::screen::AlternateScreen; -use self::termion::style as tstyle; use crossbeam_channel::{self, select, Receiver}; +use termion::color as tcolor; +use termion::event::Event as TEvent; +use termion::event::Key as TKey; +use termion::event::MouseButton as TMouseButton; +use termion::event::MouseEvent as TMouseEvent; +use termion::input::{MouseTerminal, TermRead}; +use termion::raw::{IntoRawMode, RawTerminal}; +use termion::screen::AlternateScreen; +use termion::style as tstyle; use crate::backend; use crate::backends;