Skip to content

Commit

Permalink
Implement Display and Error for EvalErr
Browse files Browse the repository at this point in the history
  • Loading branch information
Rigidity committed Aug 9, 2023
1 parent 999c4df commit 1305959
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/reduction.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::io;
use std::{fmt, io};

use crate::allocator::NodePtr;
use crate::cost::Cost;
Expand All @@ -11,6 +11,14 @@ pub struct Reduction(pub Cost, pub NodePtr);

pub type Response = Result<Reduction, EvalErr>;

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<EvalErr> for io::Error {
fn from(v: EvalErr) -> Self {
Self::new(io::ErrorKind::Other, v.1)
Expand Down

0 comments on commit 1305959

Please sign in to comment.