diff --git a/src/rstd/singular.rs b/src/rstd/singular.rs index 262dd05..3295537 100644 --- a/src/rstd/singular.rs +++ b/src/rstd/singular.rs @@ -45,7 +45,7 @@ pub struct SingularRobust<'a, Ctx: Context<'a>> { } #[derive(Debug)] -pub enum SingularityError { +pub enum SingularError { OutOfBounds { index: usize, len: usize, @@ -57,7 +57,7 @@ pub enum SingularityError { }, } -impl Display for SingularityError { +impl Display for SingularError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::OutOfBounds { index, len } => { @@ -87,16 +87,16 @@ impl<'a, Ctx: Context<'a>> SingularResolver<'a, Ctx> { fn resolve_robust( self: Arc, address: Address, - ) -> Result, SingularityError> { + ) -> Result, SingularError> { let point = self .points .get(address.index) - .ok_or(SingularityError::OutOfBounds { + .ok_or(SingularError::OutOfBounds { index: address.index, len: self.points.len(), })?; if point.s_hash() != address.point { - Err(SingularityError::Mismatch { + Err(SingularError::Mismatch { index: address.index, expected: address.point, point: point.s_hash(), @@ -114,7 +114,16 @@ impl<'a, Ctx: Context<'a>> Resolver<'a, Ctx> for SingularResolver<'a, Ctx> { } trait SingularCtx<'a>: Context<'a> { - fn from_singular(error: SingularityError) -> Self::LookupError; + fn from_singular(error: SingularError) -> Self::LookupError; +} + +impl<'a, Ctx: Context<'a>> SingularCtx<'a> for Ctx +where + Ctx::LookupError: From, +{ + fn from_singular(error: SingularError) -> Self::LookupError { + error.into() + } } impl<'a, Ctx: SingularCtx<'a>> Resolver<'a, Ctx> for SingularRobust<'a, Ctx> {