Skip to content
Myr

Extract error_if_any_error as free function

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by fusillicode · committed by David Peter · parent a5fe138 · Browse files · 3 files+11 added−11 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+11 added−11 removed

  • other:+11 added−11 removed

3 files+11 added−11 removed

modified:src/exec/job.rs+2 added-2 removed
5 unmodified lines
6// notice may not be copied, modified, or distributed except7// according to those terms.89use super::CommandTemplate;10use crate::exit_codes::ExitCode;10use crate::exit_codes::{ExitCode, error_if_any_error};11use crate::walk::WorkerResult;12use std::path::PathBuf;13use std::sync::mpsc::Receiver;14use std::sync::{Arc, Mutex};
30 unmodified lines
45 // Generate a command, execute it and store its exit code.46 results.push(cmd.generate_and_execute(&value, Arc::clone(&out_perm)))47 }48 // Returns error in case of any error.49 ExitCode::error_if_any_error(results)49 error_if_any_error(results)50}5152pub fn batch(53 rx: Receiver<WorkerResult>,
14 unmodified lines
modified:src/exit_codes.rs+7 added-7 removed
13 unmodified lines
14 }15}1617impl ExitCode {18 pub fn error_if_any_error(results: Vec<Self>) -> Self {19 if results.iter().any(ExitCode::is_error) {20 return ExitCode::GeneralError;21 }22 ExitCode::Success23 }2418 fn is_error(&self) -> bool {19 match self {20 ExitCode::GeneralError | ExitCode::KilledBySigint => true,21 _ => false,22 }23 }24}2526pub fn error_if_any_error(results: Vec<ExitCode>) -> ExitCode {27 if results.iter().any(ExitCode::is_error) {28 return ExitCode::GeneralError;29 }30 ExitCode::Success31}
modified:src/walk.rs+2 added-2 removed
5 unmodified lines
6// notice may not be copied, modified, or distributed except7// according to those terms.89use crate::exec;10use crate::exit_codes::ExitCode;10use crate::exit_codes::{ExitCode, error_if_any_error};11use crate::fshelper;12use crate::internal::{opts::FdOptions, osstr_to_bytes, MAX_BUFFER_LENGTH};13use crate::output;14
166 unmodified lines
181 for h in handles {182 results.push(h.join().unwrap());183 }184185 ExitCode::error_if_any_error(results)185 error_if_any_error(results)186 }187 } else {188 let start = time::Instant::now();189
199 unmodified lines