From d3236903fc25c678be90f5a510e8ce73ada7a71e Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Thu, 6 Aug 2020 17:38:27 +0200 Subject: [PATCH] Get rid of Error::description() --- src/schema.rs | 8 +------- tests/storage.rs | 18 ++++++------------ 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/schema.rs b/src/schema.rs index 8b1cc94..8e10697 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -22,12 +22,6 @@ pub enum SymbolRunError { } impl Error for SymbolRunError { - fn description(&self) -> &str { - match self { - Self::Symbol(_) => "Symbol execution error", - Self::ExecuteDidNotReach(_) => "Target not reached after executing symbol", - } - } fn cause(&self) -> Option<&dyn Error> { match self { Self::Symbol(ref e) => Some(&**e), @@ -40,7 +34,7 @@ impl fmt::Display for SymbolRunError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Symbol(ref e) => write!(f, "{}", e), - Self::ExecuteDidNotReach(_) => write!(f, "{}", self.description()), + Self::ExecuteDidNotReach(_) => write!(f, "Target not reached after executing symbol"), } } } diff --git a/tests/storage.rs b/tests/storage.rs index cb4bc61..4a29f9e 100644 --- a/tests/storage.rs +++ b/tests/storage.rs @@ -103,12 +103,12 @@ fn empty_storage() { ); assert!(storage.read_filename().is_err()); assert_eq!( - storage.read_filename().unwrap_err().description(), + storage.read_filename().unwrap_err().to_string(), "entity not found" ); assert!(storage.recent_date().is_err()); assert_eq!( - storage.recent_date().unwrap_err().description(), + storage.recent_date().unwrap_err().to_string(), "entity not found" ); } @@ -125,14 +125,11 @@ fn empty_storage_for_filename() { ); assert!(storage.read_filename().is_err()); assert_eq!( - storage.read_filename().unwrap_err().description(), + storage.read_filename().unwrap_err().to_string(), "Not found" ); assert!(storage.recent_date().is_err()); - assert_eq!( - storage.recent_date().unwrap_err().description(), - "Not found" - ); + assert_eq!(storage.recent_date().unwrap_err().to_string(), "Not found"); } #[test] @@ -147,12 +144,9 @@ fn bad_file() { ); assert!(storage.read_filename().is_err()); assert_eq!( - storage.read_filename().unwrap_err().description(), + storage.read_filename().unwrap_err().to_string(), "Not found" ); assert!(storage.recent_date().is_err()); - assert_eq!( - storage.recent_date().unwrap_err().description(), - "Not found" - ); + assert_eq!(storage.recent_date().unwrap_err().to_string(), "Not found"); }