diff options
author | HampusM <hampus@hampusmat.com> | 2022-11-06 17:20:45 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-11-06 17:20:45 +0100 |
commit | e282375de4ba75c69f7d619fc33c6250f6caba18 (patch) | |
tree | f09410f57ea154c834dba88d76510e2a27548956 /macros/src/libs | |
parent | 2c03974a7e7cfec8d734caa6036d9a2461694818 (diff) |
fix: allow declaring a concrete type as it's own interface
Diffstat (limited to 'macros/src/libs')
-rw-r--r-- | macros/src/libs/intertrait_macros/gen_caster.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/macros/src/libs/intertrait_macros/gen_caster.rs b/macros/src/libs/intertrait_macros/gen_caster.rs index a703a62..a76bb52 100644 --- a/macros/src/libs/intertrait_macros/gen_caster.rs +++ b/macros/src/libs/intertrait_macros/gen_caster.rs @@ -32,46 +32,46 @@ pub fn generate_caster( let new_caster = if sync { quote! { - syrette::libs::intertrait::Caster::<dyn #dst_trait>::new_sync( + syrette::libs::intertrait::Caster::<#dst_trait>::new_sync( |from| { let concrete = from .downcast::<#ty>() .map_err(|_| syrette::libs::intertrait::CasterError::CastBoxFailed)?; - Ok(concrete as Box<dyn #dst_trait>) + Ok(concrete as Box<#dst_trait>) }, |from| { let concrete = from .downcast::<#ty>() .map_err(|_| syrette::libs::intertrait::CasterError::CastRcFailed)?; - Ok(concrete as std::rc::Rc<dyn #dst_trait>) + Ok(concrete as std::rc::Rc<#dst_trait>) }, |from| { let concrete = from .downcast::<#ty>() .map_err(|_| syrette::libs::intertrait::CasterError::CastArcFailed)?; - Ok(concrete as std::sync::Arc<dyn #dst_trait>) + Ok(concrete as std::sync::Arc<#dst_trait>) }, ) } } else { quote! { - syrette::libs::intertrait::Caster::<dyn #dst_trait>::new( + syrette::libs::intertrait::Caster::<#dst_trait>::new( |from| { let concrete = from .downcast::<#ty>() .map_err(|_| syrette::libs::intertrait::CasterError::CastBoxFailed)?; - Ok(concrete as Box<dyn #dst_trait>) + Ok(concrete as Box<#dst_trait>) }, |from| { let concrete = from .downcast::<#ty>() .map_err(|_| syrette::libs::intertrait::CasterError::CastRcFailed)?; - Ok(concrete as std::rc::Rc<dyn #dst_trait>) + Ok(concrete as std::rc::Rc<#dst_trait>) }, ) } |