Extract ExitCode::is_error helper

This commit is contained in:
fusillicode 2020-02-22 09:01:52 +01:00 committed by David Peter
parent b23cfc383f
commit a5fe138a25
1 changed files with 8 additions and 4 deletions

View File

@ -16,12 +16,16 @@ impl Into<i32> for ExitCode {
impl ExitCode {
pub fn error_if_any_error(results: Vec<Self>) -> Self {
if results.iter().any(|s| match s {
ExitCode::GeneralError => true,
_ => false,
}) {
if results.iter().any(ExitCode::is_error) {
return ExitCode::GeneralError;
}
ExitCode::Success
}
fn is_error(&self) -> bool {
match self {
ExitCode::GeneralError | ExitCode::KilledBySigint => true,
_ => false,
}
}
}