From a756756a9fb816e50b6e07a8612b051c5cb51ae3 Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Sat, 26 Sep 2026 10:40:19 +0100 Subject: [PATCH] Implement std::fmt::Display for parser errors --- src/parse.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/parse.rs b/src/parse.rs index 489fa70..2ea0c8f 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -9,6 +9,15 @@ pub enum Error { InvalidSyntax, } +impl std::fmt::Display for Error { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Error::Io(err) => write!(f, "I/O Error: {}", err), + Error::InvalidSyntax => write!(f, "Invalid syntax"), + } + } +} + impl std::str::FromStr for Expression { type Err = Error;