From 80331d0a5571e2f52cd575cf9860075aa9f1867c Mon Sep 17 00:00:00 2001 From: Simon Walker Date: Wed, 26 Aug 2020 23:26:41 +0100 Subject: [PATCH] Fix some clippy lints --- src/dep_parser.rs | 2 +- src/install.rs | 50 +++++++++++++++++++++++++---------------------- src/main.rs | 6 +++--- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/dep_parser.rs b/src/dep_parser.rs index 0bf4820..cd9329a 100644 --- a/src/dep_parser.rs +++ b/src/dep_parser.rs @@ -233,7 +233,7 @@ pub fn parse_req_type(input: &str) -> IResult<&str, ReqType> { tag("~="), tag("~"), )), - |x| ReqType::from_str(x), + ReqType::from_str, )(input) } diff --git a/src/install.rs b/src/install.rs index e99fcca..99426cd 100644 --- a/src/install.rs +++ b/src/install.rs @@ -285,15 +285,13 @@ pub fn download_and_install_package( .unwrap() .to_lowercase() .contains("readme") + && fs::File::create(&paths.lib.join(f.path().unwrap())) + .is_err() { - if let Err(_) = - fs::File::create(&paths.lib.join(f.path().unwrap())) - { - print_color( - "Problem creating dummy readme", - Color::DarkYellow, - ); - } + print_color( + "Problem creating dummy readme", + Color::DarkYellow, + ); } } }; @@ -356,11 +354,13 @@ pub fn download_and_install_package( .current_dir(&extracted_parent) .args(&["setup.py", "bdist_wheel"]) .output() - .expect(&format!( - "Problem running setup.py bdist_wheel in folder: {:?}. Py path: {:?}", - &extracted_parent, - paths.bin.join("python") - )); + .unwrap_or_else(|_| { + panic!( + "Problem running setup.py bdist_wheel in folder: {:?}. Py path: {:?}", + &extracted_parent, + paths.bin.join("python") + ) + }); util::check_command_output_with(&output, |s| { panic!( "running setup.py bdist_wheel in folder {:?}. Py path: {:?}: {}", @@ -376,11 +376,13 @@ pub fn download_and_install_package( .current_dir(&extracted_parent) .args(&["setup.py", "bdist_wheel"]) .output() - .expect(&format!( - "Problem running setup.py bdist_wheel in folder: {:?}. Py path: {:?}", - &extracted_parent, - paths.bin.join("python") - )); + .unwrap_or_else(|_| { + panic!( + "Problem running setup.py bdist_wheel in folder: {:?}. Py path: {:?}", + &extracted_parent, + paths.bin.join("python") + ) + }); util::check_command_output_with(&output, |s| { panic!( "running setup.py bdist_wheel in folder {:?}. Py path: {:?}: {}", @@ -396,11 +398,13 @@ pub fn download_and_install_package( .current_dir(&extracted_parent) .args(&["setup.py", "bdist_wheel"]) .output() - .expect(&format!( - "Problem running setup.py bdist_wheel in folder: {:?}. Py path: {:?}", - &extracted_parent, - paths.bin.join("python") - )); + .unwrap_or_else(|_| { + panic!( + "Problem running setup.py bdist_wheel in folder: {:?}. Py path: {:?}", + &extracted_parent, + paths.bin.join("python") + ) + }); util::check_command_output_with(&output, |s| { panic!( "running setup.py bdist_wheel in folder {:?}. Py path: {:?}: {}", diff --git a/src/main.rs b/src/main.rs index fb20138..643e398 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1006,7 +1006,7 @@ fn run_script( Err(_) => Lock::default(), }; - let lockpacks = lock.package.unwrap_or_else(|| vec![]); + let lockpacks = lock.package.unwrap_or_else(Vec::new); let reqs: Vec = deps .iter() @@ -1463,7 +1463,7 @@ fn main() { Err(_) => Lock::default(), }; - let lockpacks = lock.package.unwrap_or_else(|| vec![]); + let lockpacks = lock.package.unwrap_or_else(Vec::new); sync( &paths, @@ -1583,7 +1583,7 @@ fn main() { &paths, &lockpacks, &updated_reqs, - &cfg.dev_reqs.clone(), + &cfg.dev_reqs, &[], os, &py_vers,