From 716473252dcabc75ce141a0fdb518f00d59700b5 Mon Sep 17 00:00:00 2001 From: fdai7451 Date: Thu, 19 Jan 2023 13:57:43 +0100 Subject: [PATCH] feat: make shell error comparable --- src/error.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/error.rs b/src/error.rs index 2f11ccf..6b24ea0 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,5 +1,6 @@ use std::process::Command; +#[derive(Debug)] pub enum ShellError { EmptyLine, Exit, @@ -7,3 +8,15 @@ pub enum ShellError { ExecuteFailure(String), MalformedArgs(String), } + +impl PartialEq 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(_)), + } + } +}