From 7e9609826c3439951b4ec2f4735d5abbabe4ee1d Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Wed, 28 Sep 2016 15:07:02 -0700 Subject: [PATCH] Fix clippy warnings --- examples/key_codes.rs | 2 +- examples/logs.rs | 18 +++++++++--------- examples/select.rs | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/key_codes.rs b/examples/key_codes.rs index 48debce..aba34b0 100644 --- a/examples/key_codes.rs +++ b/examples/key_codes.rs @@ -28,7 +28,7 @@ impl KeyCodeView { impl View for KeyCodeView { fn draw(&self, printer: &Printer) { for (y, line) in self.history.iter().enumerate() { - printer.print((0, y), &line); + printer.print((0, y), line); } } diff --git a/examples/logs.rs b/examples/logs.rs index 0c7a7d9..8403189 100644 --- a/examples/logs.rs +++ b/examples/logs.rs @@ -5,6 +5,8 @@ use cursive::prelude::*; use std::sync::mpsc; use std::thread; use std::time::Duration; +use std::iter::Chain; +use std::slice::Iter; fn main() { // As usual, create the Cursive root @@ -37,9 +39,8 @@ fn generate_logs(tx: mpsc::Sender) { i += 1; // The send will fail when the other side is dropped. // (When the application ends). - match tx.send(line) { - Err(_) => return, - Ok(_) => (), + if tx.send(line).is_err() { + return; } thread::sleep(Duration::from_millis(30)); } @@ -76,10 +77,8 @@ impl BufferView { } // Chain together the two parts of the buffer to appear as a circular one. - // The signature is quite ugly, but basically we return an iterator: - // a Chain of two slice iterators. - fn ring<'a>(&'a self) - -> std::iter::Chain, std::slice::Iter<'a, String>> { + // TODO: Use `-> impl Iterator`... + fn ring(&self) -> Chain, Iter> { // The main buffer is "circular" starting at self.pos // So we chain the two parts as one self.buffer[self.pos..].iter().chain(self.buffer[..self.pos].iter()) @@ -94,9 +93,10 @@ impl View for BufferView { fn draw(&self, printer: &Printer) { - // If the buffer is large enough, we'll discard the beginning and keep the end. + // If the buffer is large, we'll discard the beginning and keep the end. // If the buffer is too small, only print a part of it with an offset. - let (discard, offset) = if self.buffer.len() > printer.size.y as usize { + let (discard, offset) = if self.buffer.len() > + printer.size.y as usize { (self.buffer.len() - printer.size.y as usize, 0) } else { (0, printer.size.y - self.buffer.len()) diff --git a/examples/select.rs b/examples/select.rs index 8ba9d3b..08dc3ff 100644 --- a/examples/select.rs +++ b/examples/select.rs @@ -24,7 +24,7 @@ fn main() { } // Let's put the callback in a separate function to keep it clean, but it's not required. -fn show_next_window(siv: &mut Cursive, city: &String) { +fn show_next_window(siv: &mut Cursive, city: &str) { siv.pop_layer(); let text = format!("{} is a great city!", city); siv.add_layer(Dialog::new(TextView::new(text))