Browse Source

feat: make shell error comparable

main
fdai7451 2 years ago
parent
commit
716473252d
  1. 13
      src/error.rs

13
src/error.rs

@ -1,5 +1,6 @@
use std::process::Command; use std::process::Command;
#[derive(Debug)]
pub enum ShellError { pub enum ShellError {
EmptyLine, EmptyLine,
Exit, Exit,
@ -7,3 +8,15 @@ pub enum ShellError {
ExecuteFailure(String), ExecuteFailure(String),
MalformedArgs(String), MalformedArgs(String),
} }
impl PartialEq<Self> for ShellError {
fn eq(&self, other: &Self) -> bool {
match self {
&ShellError::EmptyLine => matches!(other, ShellError::EmptyLine),
&ShellError::Exit => matches!(other, ShellError::Exit),
&ShellError::NotFound(_) => matches!(other, ShellError::NotFound(_)),
&ShellError::ExecuteFailure(_) => matches!(other, ShellError::ExecuteFailure(_)),
&ShellError::MalformedArgs(_) => matches!(other, ShellError::MalformedArgs(_)),
}
}
}
Loading…
Cancel
Save