From e895fbd9f38fbc08195d838067f5ad44bf8a5748 Mon Sep 17 00:00:00 2001 From: Matthieu Guilbert Date: Thu, 11 Jun 2020 23:29:37 +0800 Subject: [PATCH] Implement Error trait for ParseError --- src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index cafca07..7b226f4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -90,6 +90,8 @@ use rust_decimal::Decimal; use rust_decimal::Error as DecimalError; use std::cmp::min; use std::collections::HashMap; +use std::error::Error; +use std::fmt; use std::num::ParseIntError; use std::str::FromStr; use std::vec::Vec; @@ -146,6 +148,14 @@ pub enum ParseError { YearMonthDayError(&'static str), } +impl fmt::Display for ParseError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:?}", self) + } +} + +impl Error for ParseError {} + type ParseResult = Result; pub(crate) fn tokenize(parse_string: &str) -> Vec {