aboutsummaryrefslogtreecommitdiff
path: root/macros/src/injectable/implementation.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-08-04 22:03:30 +0200
committerHampusM <hampus@hampusmat.com>2023-08-04 22:03:30 +0200
commitb4718494e3a1759286caca1dd34c01db6c2f1214 (patch)
tree736bde3a1647d7c26c7cc27ce3caf4de2fa665d8 /macros/src/injectable/implementation.rs
parentb4ddc1e626fbd11d784b442d246ddc5f54c35b51 (diff)
refactor!: remove SomeThreadsafePtr & move variants to SomePtr
BREAKING CHANGE: SomeThreadsafePtr has been removed and it's variants have been moved to SomePtr
Diffstat (limited to 'macros/src/injectable/implementation.rs')
-rw-r--r--macros/src/injectable/implementation.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/macros/src/injectable/implementation.rs b/macros/src/injectable/implementation.rs
index 0ea623c..575b5c4 100644
--- a/macros/src/injectable/implementation.rs
+++ b/macros/src/injectable/implementation.rs
@@ -223,6 +223,10 @@ impl<Dep: IDependency> InjectableImpl<Dep>
let self_type = &self.self_type;
let constructor = &self.constructor_method.sig.ident;
+ let dependency_idents = (0..get_dep_method_calls.len())
+ .map(|index| format_ident!("dependency_{index}"))
+ .collect::<Vec<_>>();
+
quote! {
#maybe_doc_hidden
impl #generics syrette::interfaces::async_injectable::AsyncInjectable<
@@ -256,8 +260,14 @@ impl<Dep: IDependency> InjectableImpl<Dep>
#maybe_prevent_circular_deps
+ // Dependencies can't be passed directly to the constructor
+ // because the Rust compiler becomes sad about SomePtr having
+ // a variant with a Rc inside of it and .await being called even
+ // when the Rc variant isn't even being created
+ #(let #dependency_idents = #get_dep_method_calls;)*
+
Ok(syrette::ptr::TransientPtr::new(Self::#constructor(
- #(#get_dep_method_calls),*
+ #(#dependency_idents),*
)))
})
}