aboutsummaryrefslogtreecommitdiff
path: root/src/libs/intertrait/cast/rc.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/intertrait/cast/rc.rs')
-rw-r--r--src/libs/intertrait/cast/rc.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libs/intertrait/cast/rc.rs b/src/libs/intertrait/cast/rc.rs
index 63c0024..805bcd7 100644
--- a/src/libs/intertrait/cast/rc.rs
+++ b/src/libs/intertrait/cast/rc.rs
@@ -30,12 +30,12 @@ impl<CastFromSelf: ?Sized + CastFrom> CastRc for CastFromSelf
self: Rc<Self>,
) -> Result<Rc<OtherTrait>, CastError>
{
- match get_caster::<OtherTrait>((*self).type_id()) {
- Some(caster) => Ok((caster.cast_rc)(self.rc_any())),
- None => Err(CastError::CastFailed {
+ let caster =
+ get_caster::<OtherTrait>((*self).type_id()).ok_or(CastError::CastFailed {
from: type_name::<CastFromSelf>(),
to: type_name::<OtherTrait>(),
- }),
- }
+ })?;
+
+ Ok((caster.cast_rc)(self.rc_any()))
}
}