Fix clippy warnings

This commit is contained in:
Florian Dehau 2016-11-07 22:57:13 +01:00
parent b30fede80c
commit 4f8a57d500
5 changed files with 14 additions and 23 deletions

View File

@ -161,8 +161,7 @@ impl Buffer {
x, x,
y, y,
self.area); self.area);
let index = ((y - self.area.y) * self.area.width + (x - self.area.x)) as usize; ((y - self.area.y) * self.area.width + (x - self.area.x)) as usize
index
} }
/// Returns the coordinates of a cell given its index /// Returns the coordinates of a cell given its index
@ -188,7 +187,7 @@ impl Buffer {
for s in graphemes.into_iter().take(max_index) { for s in graphemes.into_iter().take(max_index) {
self.content[index].symbol.clear(); self.content[index].symbol.clear();
self.content[index].symbol.push_str(s); self.content[index].symbol.push_str(s);
self.content[index].style = style.clone(); self.content[index].style = *style;
index += 1; index += 1;
} }
} }

View File

@ -143,26 +143,19 @@ impl Color {
} }
fn rgb_to_byte(r: u8, g: u8, b: u8) -> u16 { fn rgb_to_byte(r: u8, g: u8, b: u8) -> u16 {
(((r & 255 & 0xC0) + (g & 255 & 0xE0) >> 2 + (b & 0xE0) >> 5) & 0xFF) as u16 ((((r & 255 & 0xC0) + ((g & 255 & 0xE0) >> 2) + ((b & 0xE0) >> 5))) & 0xFF) as u16
} }
impl Into<rustbox::Color> for Color { impl Into<rustbox::Color> for Color {
fn into(self) -> rustbox::Color { fn into(self) -> rustbox::Color {
match self { match self {
Color::Reset => rustbox::Color::Default, Color::Reset => rustbox::Color::Default,
Color::Black => rustbox::Color::Black, Color::Black | Color::Gray | Color::DarkGray => rustbox::Color::Black,
Color::Red => rustbox::Color::Red, Color::Red | Color::LightRed => rustbox::Color::Red,
Color::Green => rustbox::Color::Green, Color::Green | Color::LightGreen => rustbox::Color::Green,
Color::Yellow => rustbox::Color::Yellow, Color::Yellow | Color::LightYellow => rustbox::Color::Yellow,
Color::Magenta => rustbox::Color::Magenta, Color::Magenta | Color::LightMagenta => rustbox::Color::Magenta,
Color::Cyan => rustbox::Color::Cyan, Color::Cyan | Color::LightCyan => rustbox::Color::Cyan,
Color::Gray => rustbox::Color::Black,
Color::DarkGray => rustbox::Color::Black,
Color::LightRed => rustbox::Color::Red,
Color::LightGreen => rustbox::Color::Green,
Color::LightYellow => rustbox::Color::Yellow,
Color::LightMagenta => rustbox::Color::Magenta,
Color::LightCyan => rustbox::Color::Cyan,
Color::White => rustbox::Color::White, Color::White => rustbox::Color::White,
Color::Rgb(r, g, b) => rustbox::Color::Byte(rgb_to_byte(r, g, b)), Color::Rgb(r, g, b) => rustbox::Color::Byte(rgb_to_byte(r, g, b)),
} }
@ -195,7 +188,6 @@ impl Modifier {
impl Into<rustbox::Style> for Modifier { impl Into<rustbox::Style> for Modifier {
fn into(self) -> rustbox::Style { fn into(self) -> rustbox::Style {
match self { match self {
Modifier::Reset => rustbox::RB_NORMAL,
Modifier::Bold => rustbox::RB_BOLD, Modifier::Bold => rustbox::RB_BOLD,
Modifier::Underline => rustbox::RB_UNDERLINE, Modifier::Underline => rustbox::RB_UNDERLINE,
Modifier::Invert => rustbox::RB_REVERSE, Modifier::Invert => rustbox::RB_REVERSE,

View File

@ -229,7 +229,7 @@ impl<B> Terminal<B>
/// clean outdated ones at the end of the draw call. /// clean outdated ones at the end of the draw call.
pub fn compute_layout(&mut self, group: &Group, area: &Rect) -> Vec<Rect> { pub fn compute_layout(&mut self, group: &Group, area: &Rect) -> Vec<Rect> {
let entry = self.layout_cache let entry = self.layout_cache
.entry((group.clone(), area.clone())) .entry((group.clone(), *area))
.or_insert_with(|| { .or_insert_with(|| {
let chunks = split(area, &group.direction, group.margin, &group.sizes); let chunks = split(area, &group.direction, group.margin, &group.sizes);
debug!("New layout computed:\n* Group = {:?}\n* Chunks = {:?}", debug!("New layout computed:\n* Group = {:?}\n* Chunks = {:?}",
@ -291,7 +291,7 @@ impl<B> Terminal<B>
// Clean layout cache // Clean layout cache
let hot = self.layout_cache let hot = self.layout_cache
.drain() .drain()
.filter(|&(_, ref v)| v.hot == true) .filter(|&(_, ref v)| v.hot)
.collect::<Vec<((Group, Rect), LayoutEntry)>>(); .collect::<Vec<((Group, Rect), LayoutEntry)>>();
for (key, value) in hot { for (key, value) in hot {

View File

@ -93,7 +93,7 @@ impl<'a> Widget for Gauge<'a> {
let label = self.label.unwrap_or(&precent_label); let label = self.label.unwrap_or(&precent_label);
let label_width = label.width() as u16; let label_width = label.width() as u16;
let middle = (gauge_area.width - label_width) / 2 + gauge_area.left(); let middle = (gauge_area.width - label_width) / 2 + gauge_area.left();
buf.set_string(middle, y, &label, &self.style); buf.set_string(middle, y, label, &self.style);
} }
// Fix colors // Fix colors

View File

@ -72,7 +72,7 @@ impl<'a, T> Widget for List<'a, T>
list_area.top() + i as u16, list_area.top() + i as u16,
item.as_ref(), item.as_ref(),
list_area.width as usize, list_area.width as usize,
&style); style);
} }
} }
} }
@ -193,7 +193,7 @@ impl<'a> Widget for SelectableList<'a> {
// Render items // Render items
List::default() List::default()
.block(self.block.unwrap_or(Default::default())) .block(self.block.unwrap_or_default())
.items(&items) .items(&items)
.draw(area, buf); .draw(area, buf);
} }