From abf175111d9bd997bc1c4ef5e078308fad681480 Mon Sep 17 00:00:00 2001 From: lyn <819880950@qq.com> Date: Mon, 11 Mar 2019 15:09:20 +0100 Subject: [PATCH] clippy-ify --- src/main.rs | 10 +++++----- src/run.rs | 12 ++++++------ src/verify.rs | 20 ++++++++++---------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/main.rs b/src/main.rs index 39f11dc6..0e2c9757 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,7 +36,7 @@ fn main() { let ts = ThemeSet::load_defaults(); if None == matches.subcommand_name() { - println!(""); + println!(); println!(r#" welcome to... "#); println!(r#" _ _ _ "#); println!(r#" _ __ _ _ ___| |_| (_)_ __ __ _ ___ "#); @@ -44,25 +44,25 @@ fn main() { println!(r#" | | | |_| \__ \ |_| | | | | | (_| \__ \ "#); println!(r#" |_| \__,_|___/\__|_|_|_| |_|\__, |___/ "#); println!(r#" |___/ "#); - println!(""); + println!(); } if let Some(matches) = matches.subcommand_matches("run") { run(matches.clone()).unwrap(); } - if let Some(_) = matches.subcommand_matches("verify") { + if matches.subcommand_matches("verify").is_some() { match verify() { Ok(_) => {} Err(_) => std::process::exit(1), } } - if let Some(_) = matches.subcommand_matches("watch") { + if matches.subcommand_matches("watch").is_some() { watch().unwrap(); } - if let None = matches.subcommand_name() { + if matches.subcommand_name().is_none() { let mut highlighter = HighlightFile::new("default_out.md", &ss, &ts.themes["base16-eighties.dark"]).unwrap(); for maybe_line in highlighter.reader.lines() { diff --git a/src/run.rs b/src/run.rs index b41ed33e..613ec2ba 100644 --- a/src/run.rs +++ b/src/run.rs @@ -30,17 +30,17 @@ pub fn run(matches: clap::ArgMatches) -> Result<(), ()> { } pub fn compile_and_run(filename: &str) -> Result<(), ()> { - let bar = ProgressBar::new_spinner(); - bar.set_message(format!("Compiling {}...", filename).as_str()); - bar.enable_steady_tick(100); + let progress_bar = ProgressBar::new_spinner(); + progress_bar.set_message(format!("Compiling {}...", filename).as_str()); + progress_bar.enable_steady_tick(100); let compilecmd = Command::new("rustc") .args(&[filename, "-o", "temp", "--color", "always"]) .output() .expect("fail"); - bar.set_message(format!("Running {}...", filename).as_str()); + progress_bar.set_message(format!("Running {}...", filename).as_str()); if compilecmd.status.success() { let runcmd = Command::new("./temp").output().expect("fail"); - bar.finish_and_clear(); + progress_bar.finish_and_clear(); if runcmd.status.success() { println!("{}", String::from_utf8_lossy(&runcmd.stdout)); @@ -58,7 +58,7 @@ pub fn compile_and_run(filename: &str) -> Result<(), ()> { Err(()) } } else { - bar.finish_and_clear(); + progress_bar.finish_and_clear(); let formatstr = format!( "{} Compilation of {} failed! Compiler error message:\n", Emoji("⚠️ ", "!"), diff --git a/src/verify.rs b/src/verify.rs index bc44dfac..ab08a277 100644 --- a/src/verify.rs +++ b/src/verify.rs @@ -19,14 +19,14 @@ pub fn verify() -> Result<(), ()> { } fn compile_only(filename: &str) -> Result<(), ()> { - let bar = ProgressBar::new_spinner(); - bar.set_message(format!("Compiling {}...", filename).as_str()); - bar.enable_steady_tick(100); + let progress_bar = ProgressBar::new_spinner(); + progress_bar.set_message(format!("Compiling {}...", filename).as_str()); + progress_bar.enable_steady_tick(100); let compilecmd = Command::new("rustc") .args(&[filename, "-o", "temp", "--color", "always"]) .output() .expect("fail"); - bar.finish_and_clear(); + progress_bar.finish_and_clear(); if compilecmd.status.success() { let formatstr = format!( "{} Successfully compiled {}!", @@ -50,17 +50,17 @@ fn compile_only(filename: &str) -> Result<(), ()> { } pub fn test(filename: &str) -> Result<(), ()> { - let bar = ProgressBar::new_spinner(); - bar.set_message(format!("Testing {}...", filename).as_str()); - bar.enable_steady_tick(100); + let progress_bar = ProgressBar::new_spinner(); + progress_bar.set_message(format!("Testing {}...", filename).as_str()); + progress_bar.enable_steady_tick(100); let testcmd = Command::new("rustc") .args(&["--test", filename, "-o", "temp", "--color", "always"]) .output() .expect("fail"); if testcmd.status.success() { - bar.set_message(format!("Running {}...", filename).as_str()); + progress_bar.set_message(format!("Running {}...", filename).as_str()); let runcmd = Command::new("./temp").output().expect("fail"); - bar.finish_and_clear(); + progress_bar.finish_and_clear(); if runcmd.status.success() { let formatstr = format!("{} Successfully tested {}!", Emoji("✅", "✓"), filename); @@ -79,7 +79,7 @@ pub fn test(filename: &str) -> Result<(), ()> { Err(()) } } else { - bar.finish_and_clear(); + progress_bar.finish_and_clear(); let formatstr = format!( "{} Compiling of {} failed! Please try again. Here's the output:", Emoji("⚠️ ", "!"),