From 41c02a2812116818bbcc5dc722fe2dd9cb0dfb34 Mon Sep 17 00:00:00 2001 From: Rigidity <35380458+Rigidity@users.noreply.github.com> Date: Thu, 10 Aug 2023 09:43:18 -0400 Subject: [PATCH] Implement Display and Error for EvalErr (#334) --- src/reduction.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/reduction.rs b/src/reduction.rs index 463f10a7..8cf6f3ca 100644 --- a/src/reduction.rs +++ b/src/reduction.rs @@ -1,4 +1,4 @@ -use std::io; +use std::{fmt, io}; use crate::allocator::NodePtr; use crate::cost::Cost; @@ -11,6 +11,14 @@ pub struct Reduction(pub Cost, pub NodePtr); pub type Response = Result; +impl fmt::Display for EvalErr { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "Error at {:?}: {}", self.0, self.1) + } +} + +impl std::error::Error for EvalErr {} + impl From for io::Error { fn from(v: EvalErr) -> Self { Self::new(io::ErrorKind::Other, v.1)