From 1305959e47aba887d150aca92eae643c5453253d Mon Sep 17 00:00:00 2001 From: Rigidity Date: Wed, 9 Aug 2023 17:13:11 -0400 Subject: [PATCH] Implement Display and Error for EvalErr --- 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)