mirror of https://github.com/sharkdp/fd.git
Extract ExitCode::is_error helper
This commit is contained in:
parent
b23cfc383f
commit
a5fe138a25
|
@ -16,12 +16,16 @@ impl Into<i32> for ExitCode {
|
||||||
|
|
||||||
impl ExitCode {
|
impl ExitCode {
|
||||||
pub fn error_if_any_error(results: Vec<Self>) -> Self {
|
pub fn error_if_any_error(results: Vec<Self>) -> Self {
|
||||||
if results.iter().any(|s| match s {
|
if results.iter().any(ExitCode::is_error) {
|
||||||
ExitCode::GeneralError => true,
|
|
||||||
_ => false,
|
|
||||||
}) {
|
|
||||||
return ExitCode::GeneralError;
|
return ExitCode::GeneralError;
|
||||||
}
|
}
|
||||||
ExitCode::Success
|
ExitCode::Success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_error(&self) -> bool {
|
||||||
|
match self {
|
||||||
|
ExitCode::GeneralError | ExitCode::KilledBySigint => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue