mirror of
https://github.com/sharkdp/fd
synced 2024-07-25 04:14:33 +00:00
Extract error_if_any_error as free function
This commit is contained in:
parent
a5fe138a25
commit
e23398e6d0
|
@ -7,7 +7,7 @@
|
|||
// according to those terms.
|
||||
|
||||
use super::CommandTemplate;
|
||||
use crate::exit_codes::ExitCode;
|
||||
use crate::exit_codes::{ExitCode, error_if_any_error};
|
||||
use crate::walk::WorkerResult;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::mpsc::Receiver;
|
||||
|
@ -46,7 +46,7 @@ pub fn job(
|
|||
results.push(cmd.generate_and_execute(&value, Arc::clone(&out_perm)))
|
||||
}
|
||||
// Returns error in case of any error.
|
||||
ExitCode::error_if_any_error(results)
|
||||
error_if_any_error(results)
|
||||
}
|
||||
|
||||
pub fn batch(
|
||||
|
|
|
@ -15,13 +15,6 @@ impl Into<i32> for ExitCode {
|
|||
}
|
||||
|
||||
impl ExitCode {
|
||||
pub fn error_if_any_error(results: Vec<Self>) -> Self {
|
||||
if results.iter().any(ExitCode::is_error) {
|
||||
return ExitCode::GeneralError;
|
||||
}
|
||||
ExitCode::Success
|
||||
}
|
||||
|
||||
fn is_error(&self) -> bool {
|
||||
match self {
|
||||
ExitCode::GeneralError | ExitCode::KilledBySigint => true,
|
||||
|
@ -29,3 +22,10 @@ impl ExitCode {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn error_if_any_error(results: Vec<ExitCode>) -> ExitCode {
|
||||
if results.iter().any(ExitCode::is_error) {
|
||||
return ExitCode::GeneralError;
|
||||
}
|
||||
ExitCode::Success
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
// according to those terms.
|
||||
|
||||
use crate::exec;
|
||||
use crate::exit_codes::ExitCode;
|
||||
use crate::exit_codes::{ExitCode, error_if_any_error};
|
||||
use crate::fshelper;
|
||||
use crate::internal::{opts::FdOptions, osstr_to_bytes, MAX_BUFFER_LENGTH};
|
||||
use crate::output;
|
||||
|
@ -182,7 +182,7 @@ fn spawn_receiver(
|
|||
results.push(h.join().unwrap());
|
||||
}
|
||||
|
||||
ExitCode::error_if_any_error(results)
|
||||
error_if_any_error(results)
|
||||
}
|
||||
} else {
|
||||
let start = time::Instant::now();
|
||||
|
|
Loading…
Reference in a new issue