diff options
author | HampusM <hampus@hampusmat.com> | 2022-11-08 21:43:38 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-11-08 21:43:38 +0100 |
commit | 105d289e1926055783d8804734b299dae10bc464 (patch) | |
tree | 2918ea36714dcae6d12361e2e9bea45f32965fbf | |
parent | 56f5273c02c295831aff34b3f20e66fd1c1e0bc0 (diff) |
fix: allow for concrete type interfaces to be marked async
-rw-r--r-- | macros/src/lib.rs | 24 |
1 files changed, 14 insertions, 10 deletions
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! {} |