style: fix clippy warnings

This commit is contained in:
Florian Dehau 2019-02-03 22:07:58 +01:00
parent 5bc617a9a6
commit b669cf9ce7
13 changed files with 21 additions and 17 deletions

View file

@ -11,7 +11,7 @@ use termion::screen::AlternateScreen;
use tui::backend::TermionBackend;
use tui::layout::{Constraint, Direction, Layout, Rect};
use tui::style::Color;
use tui::widgets::canvas::{Canvas, Line, Map, MapResolution, Rectangle};
use tui::widgets::canvas::{Canvas, Map, MapResolution, Rectangle};
use tui::widgets::{Block, Borders, Widget};
use tui::Terminal;

View file

@ -10,12 +10,18 @@ pub struct CrosstermBackend {
screen: crossterm::Screen,
}
impl CrosstermBackend {
pub fn new() -> CrosstermBackend {
impl Default for CrosstermBackend {
fn default() -> CrosstermBackend {
CrosstermBackend {
screen: crossterm::Screen::default(),
}
}
}
impl CrosstermBackend {
pub fn new() -> CrosstermBackend {
CrosstermBackend::default()
}
pub fn screen(&self) -> &crossterm::Screen {
&self.screen

View file

@ -13,7 +13,7 @@ pub struct RustboxBackend {
impl RustboxBackend {
pub fn new() -> Result<RustboxBackend, rustbox::InitError> {
let rustbox = r#try!(rustbox::RustBox::init(Default::default()));
Ok(RustboxBackend { rustbox: rustbox })
Ok(RustboxBackend { rustbox })
}
pub fn with_rustbox(instance: rustbox::RustBox) -> RustboxBackend {

View file

@ -187,10 +187,8 @@ impl Buffer {
width,
height,
});
let mut y = 0;
for line in &lines {
buffer.set_string(0, y, line, Style::default());
y += 1;
for (y, line) in lines.iter().enumerate() {
buffer.set_string(0, y as u16, line, Style::default());
}
buffer
}

View file

@ -120,7 +120,7 @@ impl<'a> Widget for BarChart<'a> {
return;
}
self.background(&chart_area, buf, self.style.bg);
self.background(chart_area, buf, self.style.bg);
let max = self
.max

View file

@ -103,7 +103,7 @@ impl<'a> Widget for Block<'a> {
return;
}
self.background(&area, buf, self.style.bg);
self.background(area, buf, self.style.bg);
// Sides
if self.borders.intersects(Borders::LEFT) {

View file

@ -356,7 +356,7 @@ where
return;
}
self.background(&chart_area, buf, self.style.bg);
self.background(chart_area, buf, self.style.bg);
if let Some((x, y)) = layout.title_x {
let title = self.x_axis.title.unwrap();

View file

@ -87,7 +87,7 @@ impl<'a> Widget for Gauge<'a> {
}
if self.style.bg != Color::Reset {
self.background(&gauge_area, buf, self.style.bg);
self.background(gauge_area, buf, self.style.bg);
}
let center = gauge_area.height / 2 + gauge_area.top();

View file

@ -86,7 +86,7 @@ where
return;
}
self.background(&list_area, buf, self.style.bg);
self.background(list_area, buf, self.style.bg);
for (i, item) in self
.items

View file

@ -68,7 +68,7 @@ pub trait Widget {
/// implement a custom widget.
fn draw(&mut self, area: Rect, buf: &mut Buffer);
/// Helper method to quickly set the background of all cells inside the specified area.
fn background(&self, area: &Rect, buf: &mut Buffer, color: Color) {
fn background(&self, area: Rect, buf: &mut Buffer, color: Color) {
for y in area.top()..area.bottom() {
for x in area.left()..area.right() {
buf.get_mut(x, y).set_bg(color);

View file

@ -120,7 +120,7 @@ where
return;
}
self.background(&text_area, buf, self.style.bg);
self.background(text_area, buf, self.style.bg);
let style = self.style;
let mut styled = self.text.by_ref().flat_map(|t| match *t {

View file

@ -167,7 +167,7 @@ where
};
// Set the background
self.background(&table_area, buf, self.style.bg);
self.background(table_area, buf, self.style.bg);
// Save widths of the columns that will fit in the given area
let mut x = 0;

View file

@ -109,7 +109,7 @@ where
return;
}
self.background(&tabs_area, buf, self.style.bg);
self.background(tabs_area, buf, self.style.bg);
let mut x = tabs_area.left();
let titles_length = self.titles.len();