diff --git a/src/executor.rs b/src/executor.rs index 87b320dc..70472811 100644 --- a/src/executor.rs +++ b/src/executor.rs @@ -230,15 +230,6 @@ pub enum ExecutorExitStatus { Dry, } -impl Check for ExecutorExitStatus { - fn check(self) -> Result<()> { - match self { - ExecutorExitStatus::Wet(e) => e.check(), - ExecutorExitStatus::Dry => Ok(()), - } - } -} - impl CheckWithCodes for ExecutorExitStatus { fn check_with_codes(self, codes: &[i32]) -> Result<()> { match self { diff --git a/src/utils.rs b/src/utils.rs index 7442f69b..c9399567 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -12,16 +12,6 @@ pub trait Check { fn check(self) -> Result<()>; } -impl Check for ExitStatus { - fn check(self) -> Result<()> { - if self.success() { - Ok(()) - } else { - Err(TopgradeError::ProcessFailed(self).into()) - } - } -} - impl Check for Output { fn check(self) -> Result<()> { self.status.check() @@ -32,6 +22,14 @@ pub trait CheckWithCodes { fn check_with_codes(self, codes: &[i32]) -> Result<()>; } +// Anything that implements CheckWithCodes also implements check +// if check_with_codes is given an empty array of codes to check +impl Check for T { + fn check(self) -> Result<()> { + self.check_with_codes(&[]) + } +} + impl CheckWithCodes for ExitStatus { fn check_with_codes(self, codes: &[i32]) -> Result<()> { // Set the default to be -1 because the option represents a signal termination