From b7f7cc7d3faee489657fa3bb373a40a0d96e1938 Mon Sep 17 00:00:00 2001 From: Dario Curreri Date: Tue, 20 Feb 2024 12:48:00 +0100 Subject: [PATCH] Implement PartialEq for errors --- env-settings-utils/src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/env-settings-utils/src/lib.rs b/env-settings-utils/src/lib.rs index 7e6991b..bf148f4 100644 --- a/env-settings-utils/src/lib.rs +++ b/env-settings-utils/src/lib.rs @@ -28,6 +28,21 @@ pub enum EnvSettingsError { NotExists(&'static str), } +impl PartialEq for EnvSettingsError { + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (Self::Convert(l0, l1, l2), Self::Convert(r0, r1, r2)) => { + l0 == r0 && l1 == r1 && l2 == r2 + } + (Self::File(l0, l1), Self::File(r0, r1)) => { + l0 == r0 && l1.to_string() == r1.to_string() + } + (Self::NotExists(l0), Self::NotExists(r0)) => l0 == r0, + _ => false, + } + } +} + /// Get the environment variables pub fn get_env_variables(case_insensitive: bool) -> collections::HashMap { let env_variables = env::vars();