From 4fd0d6b4951b08a20d5378bca75561109dc6d036 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 18 Sep 2023 22:35:58 +0200 Subject: 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 --- src/di_container/asynchronous/binding/when_configurator.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/di_container/asynchronous/binding/when_configurator.rs') 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 +pub struct AsyncBindingWhenConfigurator<'di_container, Interface> where Interface: 'static + ?Sized + Send + Sync, { - di_container: Arc, + di_container: &'di_container AsyncDIContainer, interface_phantom: PhantomData, } -impl AsyncBindingWhenConfigurator +impl<'di_container, Interface> AsyncBindingWhenConfigurator<'di_container, Interface> where Interface: 'static + ?Sized + Send + Sync, { - pub(crate) fn new(di_container: Arc) -> 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") -- cgit v1.2.3-18-g5258