From 970b7669a463a5d0b3fcb7bfab439dad67e532f7 Mon Sep 17 00:00:00 2001 From: Guillaume Pasquet Date: Sat, 2 Apr 2022 07:28:47 +0000 Subject: Resolve "Fix all clippy advice" --- src/main.rs | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 6ebfc45..df12e1e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -68,9 +68,9 @@ impl Args { } } -fn read_file_barb(file_name: &String) -> Result { +fn read_file_barb(file_name: &str) -> Result { BarbFile::from_file(file_name.to_string()) - .map_err(|_| String::from(format!("Failed to parse file {}", file_name))) + .map_err(|_| format!("Failed to parse file {}", file_name)) } fn main() { @@ -79,18 +79,20 @@ fn main() { let mut executor = Executor::new(Context::new(env::vars())); let output = args.output(); - let files: Vec> = args.files_iter().map(read_file_barb).collect(); + let files: Vec> = + args.files_iter().map(|x| read_file_barb(x)).collect(); - let (maybe_deps, errors): (Vec>, Vec>) = - files - .iter() - .map(|x| match x.as_ref().ok() { - Some(bfile) => bfile.dependency(), - None => None, - }) - .filter(|x| x.is_some()) - .map(|x| read_file_barb(&String::from(x.unwrap()))) - .partition(|x| x.is_ok()); + type MaybeBarbFiles = Vec>; + + let (maybe_deps, errors): (MaybeBarbFiles, MaybeBarbFiles) = files + .iter() + .map(|x| match x.as_ref().ok() { + Some(bfile) => bfile.dependency(), + None => None, + }) + .filter(|x| x.is_some()) + .map(|x| read_file_barb(&x.unwrap())) + .partition(|x| x.is_ok()); for e in errors { println!("{}", e.err().unwrap()); @@ -104,7 +106,7 @@ fn main() { dependencies.dedup(); for dep in dependencies { - match executor.execute_dep(&dep, &output) { + match executor.execute_dep(dep, &output) { Ok(()) => (), Err(err) => println!("{}", err), } -- cgit v1.2.3