From 9f5d5a8b533aa20ebbc037ba4a0b65ba8da486a8 Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Thu, 6 Sep 2018 15:17:03 +0300 Subject: [PATCH] Fix some comments by Clippy --- src/executor.rs | 13 +++++++------ src/terminal.rs | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/executor.rs b/src/executor.rs index 5cb2bcfb..9f76af2b 100644 --- a/src/executor.rs +++ b/src/executor.rs @@ -12,12 +12,13 @@ pub enum Executor { impl Executor { pub fn new>(program: S, dry: bool) -> Self { - match dry { - false => Executor::Wet(Command::new(program)), - true => Executor::Dry(DryCommand { + if dry { + Executor::Dry(DryCommand { program: program.as_ref().into(), ..Default::default() - }), + }) + } else { + Executor::Wet(Command::new(program)) } } @@ -64,7 +65,7 @@ impl Executor { pub fn spawn(&mut self) -> Result { match self { - Executor::Wet(c) => c.spawn().map(|c| ExecutorChild::Wet(c)), + Executor::Wet(c) => c.spawn().map(ExecutorChild::Wet), Executor::Dry(c) => { print!( "Dry running: {} {}", @@ -100,7 +101,7 @@ pub enum ExecutorChild { impl ExecutorChild { pub fn wait(&mut self) -> Result { match self { - ExecutorChild::Wet(c) => c.wait().map(|s| ExecutorExitStatus::Wet(s)), + ExecutorChild::Wet(c) => c.wait().map(ExecutorExitStatus::Wet), ExecutorChild::Dry => Ok(ExecutorExitStatus::Dry), } } diff --git a/src/terminal.rs b/src/terminal.rs index 83d28c0a..c2e2d2e1 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -71,7 +71,7 @@ impl Terminal { if self.width.is_none() { return false; } - println!(""); + println!(); loop { let mut result = String::new(); @@ -82,7 +82,7 @@ impl Terminal { let _ = self.stdout.reset(); let _ = self.stdout.flush(); - if let Ok(_) = stdin().read_line(&mut result) { + if stdin().read_line(&mut result).is_ok() { match result.as_str() { "y\n" | "Y\n" => return true, "n\n" | "N\n" | "\n" => return false,