diff options
author | HampusM <hampus@hampusmat.com> | 2023-09-18 22:35:58 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2023-09-18 22:35:58 +0200 |
commit | 4fd0d6b4951b08a20d5378bca75561109dc6d036 (patch) | |
tree | 8496d679e7ee3debcd415ed563911e2166594212 /src/di_container/asynchronous/binding/when_configurator.rs | |
parent | de2e1349f459f7f69226b2decd366be690426ea7 (diff) |
refactor!: make the async DI container not inside a Arc
BREAKING CHANGE: The async DI container is no longer inside of a Arc. This affects AsyncBindingBuilder, AsyncBindingScopeConfigurator, AsyncBindingWhenConfigurator & AsyncInjectable
Diffstat (limited to 'src/di_container/asynchronous/binding/when_configurator.rs')
-rw-r--r-- | src/di_container/asynchronous/binding/when_configurator.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/di_container/asynchronous/binding/when_configurator.rs b/src/di_container/asynchronous/binding/when_configurator.rs index 3c1de7c..b7c2767 100644 --- a/src/di_container/asynchronous/binding/when_configurator.rs +++ b/src/di_container/asynchronous/binding/when_configurator.rs @@ -1,7 +1,6 @@ //! When configurator for a binding for types inside of a [`AsyncDIContainer`]. use std::any::type_name; use std::marker::PhantomData; -use std::sync::Arc; use crate::di_container::BindingOptions; use crate::errors::async_di_container::AsyncBindingWhenConfiguratorError; @@ -10,20 +9,20 @@ use crate::util::use_double; use_double!(crate::di_container::asynchronous::AsyncDIContainer); /// When configurator for a binding for type `Interface` inside a [`AsyncDIContainer`]. -pub struct AsyncBindingWhenConfigurator<Interface> +pub struct AsyncBindingWhenConfigurator<'di_container, Interface> where Interface: 'static + ?Sized + Send + Sync, { - di_container: Arc<AsyncDIContainer>, + di_container: &'di_container AsyncDIContainer, interface_phantom: PhantomData<Interface>, } -impl<Interface> AsyncBindingWhenConfigurator<Interface> +impl<'di_container, Interface> AsyncBindingWhenConfigurator<'di_container, Interface> where Interface: 'static + ?Sized + Send + Sync, { - pub(crate) fn new(di_container: Arc<AsyncDIContainer>) -> Self + pub(crate) fn new(di_container: &'di_container AsyncDIContainer) -> Self { Self { di_container, @@ -90,7 +89,7 @@ mod tests let binding_when_configurator = AsyncBindingWhenConfigurator::< dyn subjects_async::INumber, - >::new(Arc::new(di_container_mock)); + >::new(&di_container_mock); assert!(binding_when_configurator .when_named("awesome") |