From a10825e91a1daabe420c22eb9db459740f6075c8 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sat, 23 Nov 2024 18:58:45 +0200 Subject: [PATCH] implement Display trait for Error --- src/profile/identity/gemini/memory/error.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/profile/identity/gemini/memory/error.rs b/src/profile/identity/gemini/memory/error.rs index 317dfec5..691abaab 100644 --- a/src/profile/identity/gemini/memory/error.rs +++ b/src/profile/identity/gemini/memory/error.rs @@ -1,3 +1,5 @@ +use std::fmt::{Display, Formatter, Result}; + #[derive(Debug)] pub enum Error { Clear, @@ -6,17 +8,15 @@ pub enum Error { Unexpected, } -impl Error { - pub fn to_string(&self) -> String { +impl Display for Error { + fn fmt(&self, f: &mut Formatter) -> Result { match self { - Self::Clear => "Could not cleanup memory index".to_string(), + Self::Clear => write!(f, "Could not cleanup memory index"), Self::NotFound(key) => { - format!("Record `{key}` not found in memory index") + write!(f, "Record `{key}` not found in memory index") } - Self::Overwrite(key) => { - format!("Overwrite attempt for existing record `{key}`") - } - Self::Unexpected => "Unexpected error".to_string(), + Self::Overwrite(key) => write!(f, "Overwrite attempt for existing record `{key}`"), + Self::Unexpected => write!(f, "Unexpected error"), } } }