From 4e8951ff740bddb39d9782c18ed85898d0b978fb Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 10 Nov 2022 21:48:55 +0100 Subject: refactor: improve type param names, docs & more of casting --- src/libs/intertrait/cast/rc.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 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 906490d..8567d1e 100644 --- a/src/libs/intertrait/cast/rc.rs +++ b/src/libs/intertrait/cast/rc.rs @@ -17,26 +17,22 @@ use crate::libs::intertrait::{get_caster, CastFrom}; pub trait CastRc { - /// Casts an `Rc` for this trait into that for type `OtherTrait`. - fn cast( - self: Rc, - ) -> Result, CastError>; + /// Casts an `Rc` with `Self `into a `Rc` with `Dest`. + fn cast(self: Rc) -> Result, CastError>; } /// A blanket implementation of `CastRc` for traits extending `CastFrom`. impl CastRc for CastFromSelf { - fn cast( - self: Rc, - ) -> Result, CastError> + fn cast(self: Rc) -> Result, CastError> { - let caster = get_caster::((*self).type_id()) - .map_err(CastError::GetCasterFailed)?; + let caster = + get_caster::((*self).type_id()).map_err(CastError::GetCasterFailed)?; (caster.cast_rc)(self.rc_any()).map_err(|err| CastError::CastFailed { source: err, from: type_name::(), - to: type_name::(), + to: type_name::(), }) } } -- cgit v1.2.3-18-g5258