From 8c66b98bca6ed0a2990903fe8e0ea72def5c7be8 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 21 Aug 2022 14:19:07 +0200 Subject: refactor!: change errors to be more sane BREAKING CHANGE: Major improvements have been made to error types and the error_stack crate is no longer used --- src/libs/intertrait/cast/rc.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/libs/intertrait/cast/rc.rs') diff --git a/src/libs/intertrait/cast/rc.rs b/src/libs/intertrait/cast/rc.rs index 6cd377e..dfb71c2 100644 --- a/src/libs/intertrait/cast/rc.rs +++ b/src/libs/intertrait/cast/rc.rs @@ -12,8 +12,6 @@ use std::any::type_name; use std::rc::Rc; -use error_stack::report; - use crate::libs::intertrait::cast::error::CastError; use crate::libs::intertrait::{caster, CastFrom}; @@ -22,7 +20,7 @@ pub trait CastRc /// Casts an `Rc` for this trait into that for type `OtherTrait`. fn cast( self: Rc, - ) -> error_stack::Result, CastError>; + ) -> Result, CastError>; } /// A blanket implementation of `CastRc` for traits extending `CastFrom`. @@ -30,15 +28,14 @@ impl CastRc for CastFromSelf { fn cast( self: Rc, - ) -> error_stack::Result, CastError> + ) -> Result, CastError> { match caster::((*self).type_id()) { Some(caster) => Ok((caster.cast_rc)(self.rc_any())), - None => Err(report!(CastError).attach_printable(format!( - "From {} to {}", - type_name::(), - type_name::() - ))), + None => Err(CastError::CastFailed { + from: type_name::(), + to: type_name::(), + }), } } } -- cgit v1.2.3-18-g5258