diff options
author | HampusM <hampus@hampusmat.com> | 2023-09-16 16:04:47 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2023-09-16 16:04:47 +0200 |
commit | 75ca777bbeb618e14b1cf8854ebb37b7a2c884b5 (patch) | |
tree | a03e6346b0a9b6a584edf5e4feca826f12a35d17 /src/di_container/blocking | |
parent | 31f7949ab380bcd0a0b754588e7d50284d2f5ae7 (diff) |
refactor: make castable factory take DI container param
Diffstat (limited to 'src/di_container/blocking')
-rw-r--r-- | src/di_container/blocking/mod.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/di_container/blocking/mod.rs b/src/di_container/blocking/mod.rs index 1ee0294..702141a 100644 --- a/src/di_container/blocking/mod.rs +++ b/src/di_container/blocking/mod.rs @@ -209,7 +209,7 @@ impl DIContainer use crate::private::factory::IFactory; let factory = factory_binding - .cast::<dyn IFactory<(Rc<DIContainer>,), Interface>>() + .cast::<dyn IFactory<Interface, Self>>() .map_err(|_| DIContainerError::CastFailed { interface: type_name::<Interface>(), binding_kind: "factory", @@ -222,11 +222,13 @@ impl DIContainer use crate::private::factory::IFactory; use crate::ptr::TransientPtr; + type DefaultFactoryFn<Interface> = dyn IFactory< + dyn Fn<(), Output = TransientPtr<Interface>>, + DIContainer, + >; + let default_factory = factory_binding - .cast::<dyn IFactory< - (Rc<DIContainer>,), - dyn Fn<(), Output = TransientPtr<Interface>>, - >>() + .cast::<DefaultFactoryFn<Interface>>() .map_err(|_| DIContainerError::CastFailed { interface: type_name::<Interface>(), binding_kind: "default factory", |