From 105d289e1926055783d8804734b299dae10bc464 Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 8 Nov 2022 21:43:38 +0100 Subject: fix: allow for concrete type interfaces to be marked async --- macros/src/lib.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'macros') diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 832963e..ccd38e1 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -163,19 +163,23 @@ pub fn injectable(args_stream: TokenStream, impl_stream: TokenStream) -> TokenSt let self_type = &injectable_impl.self_type; - let maybe_decl_interface = if interface.is_some() { - if is_async { - quote! { - syrette::declare_interface!(#self_type -> #interface, async = true); - } + let opt_interface = interface.map(Type::Path).or_else(|| { + if no_declare_concrete_interface { + None } else { - quote! { - syrette::declare_interface!(#self_type -> #interface); - } + Some(self_type.clone()) } - } else if !no_declare_concrete_interface { + }); + + let maybe_decl_interface = if let Some(interface) = opt_interface { + let async_flag = if is_async { + quote! {, async = true} + } else { + quote! {} + }; + quote! { - syrette::declare_interface!(#self_type -> #self_type); + syrette::declare_interface!(#self_type -> #interface #async_flag); } } else { quote! {} -- cgit v1.2.3-18-g5258