From b0a1af1e312f23eff7fe68ae17132ccded5cf31c Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 4 Oct 2023 11:10:36 +0200 Subject: refactor!: remove mutex in AsyncDIContainer BREAKING CHANGE: Multiple async DI container binding builder & binding configurator functions are no longer async --- src/di_container/asynchronous/binding/builder.rs | 160 +++++++-------- .../asynchronous/binding/scope_configurator.rs | 52 +++-- .../asynchronous/binding/when_configurator.rs | 24 +-- src/di_container/asynchronous/mod.rs | 216 +++++++-------------- 4 files changed, 170 insertions(+), 282 deletions(-) (limited to 'src') diff --git a/src/di_container/asynchronous/binding/builder.rs b/src/di_container/asynchronous/binding/builder.rs index db73ad2..5e77c24 100644 --- a/src/di_container/asynchronous/binding/builder.rs +++ b/src/di_container/asynchronous/binding/builder.rs @@ -24,7 +24,7 @@ pub struct AsyncBindingBuilder<'di_container, Interface> where Interface: 'static + ?Sized + Send + Sync, { - di_container: &'di_container AsyncDIContainer, + di_container: &'di_container mut AsyncDIContainer, dependency_history_factory: fn() -> DependencyHistory, interface_phantom: PhantomData, @@ -35,7 +35,7 @@ where Interface: 'static + ?Sized + Send + Sync, { pub(crate) fn new( - di_container: &'di_container AsyncDIContainer, + di_container: &'di_container mut AsyncDIContainer, dependency_history_factory: fn() -> DependencyHistory, ) -> Self { @@ -82,12 +82,12 @@ where /// # { /// # let mut di_container = AsyncDIContainer::new(); /// # - /// di_container.bind::().to::().await?; + /// di_container.bind::().to::()?; /// # /// # Ok(()) /// # } /// ``` - pub async fn to( + pub fn to( self, ) -> Result< AsyncBindingScopeConfigurator<'di_container, Interface, Implementation>, @@ -99,7 +99,6 @@ where if self .di_container .has_binding::(BindingOptions::new()) - .await { return Err(AsyncBindingBuilderError::BindingAlreadyExists(type_name::< Interface, @@ -107,12 +106,12 @@ where ))); } - let binding_scope_configurator = AsyncBindingScopeConfigurator::new( + let mut binding_scope_configurator = AsyncBindingScopeConfigurator::new( self.di_container, self.dependency_history_factory, ); - binding_scope_configurator.set_in_transient_scope().await; + binding_scope_configurator.set_in_transient_scope(); Ok(binding_scope_configurator) } @@ -150,23 +149,20 @@ where /// # { /// # let mut di_container = AsyncDIContainer::new(); /// # - /// di_container - /// .bind::() - /// .to_factory(&|_| { - /// Box::new(|num, some_str| { - /// let bar = TransientPtr::new(Bar { num, some_str }); + /// di_container.bind::().to_factory(&|_| { + /// Box::new(|num, some_str| { + /// let bar = TransientPtr::new(Bar { num, some_str }); /// - /// bar as TransientPtr - /// }) + /// bar as TransientPtr /// }) - /// .await?; + /// })?; /// # /// # Ok(()) /// # } /// ``` #[cfg(feature = "factory")] #[cfg_attr(doc_cfg, doc(cfg(feature = "factory")))] - pub async fn to_factory( + pub fn to_factory( self, factory_func: &'static FactoryFunc, ) -> Result< @@ -185,7 +181,6 @@ where if self .di_container .has_binding::(BindingOptions::new()) - .await { return Err(AsyncBindingBuilderError::BindingAlreadyExists(type_name::< Interface, @@ -195,15 +190,13 @@ where let factory_impl = ThreadsafeCastableFactory::new(factory_func); - self.di_container - .set_binding::( - BindingOptions::new(), - Box::new(crate::provider::r#async::AsyncFactoryProvider::new( - crate::ptr::ThreadsafeFactoryPtr::new(factory_impl), - AsyncFactoryVariant::Normal, - )), - ) - .await; + self.di_container.set_binding::( + BindingOptions::new(), + Box::new(crate::provider::r#async::AsyncFactoryProvider::new( + crate::ptr::ThreadsafeFactoryPtr::new(factory_impl), + AsyncFactoryVariant::Normal, + )), + ); Ok(AsyncBindingWhenConfigurator::new(self.di_container)) } @@ -246,27 +239,24 @@ where /// # { /// # let mut di_container = AsyncDIContainer::new(); /// # - /// di_container - /// .bind::() - /// .to_async_factory(&|_| { - /// Box::new(|num, some_str| { - /// Box::pin(async move { - /// let bar = TransientPtr::new(Bar { num, some_str }); + /// di_container.bind::().to_async_factory(&|_| { + /// Box::new(|num, some_str| { + /// Box::pin(async move { + /// let bar = TransientPtr::new(Bar { num, some_str }); /// - /// tokio::time::sleep(Duration::from_secs(2)).await; + /// tokio::time::sleep(Duration::from_secs(2)).await; /// - /// bar as TransientPtr - /// }) + /// bar as TransientPtr /// }) /// }) - /// .await?; + /// })?; /// # /// # Ok(()) /// # } /// ``` #[cfg(feature = "factory")] #[cfg_attr(doc_cfg, doc(cfg(feature = "factory")))] - pub async fn to_async_factory( + pub fn to_async_factory( self, factory_func: &'static FactoryFunc, ) -> Result< @@ -290,7 +280,6 @@ where if self .di_container .has_binding::(BindingOptions::new()) - .await { return Err(AsyncBindingBuilderError::BindingAlreadyExists(type_name::< Interface, @@ -300,15 +289,13 @@ where let factory_impl = ThreadsafeCastableFactory::new(factory_func); - self.di_container - .set_binding::( - BindingOptions::new(), - Box::new(crate::provider::r#async::AsyncFactoryProvider::new( - crate::ptr::ThreadsafeFactoryPtr::new(factory_impl), - AsyncFactoryVariant::Normal, - )), - ) - .await; + self.di_container.set_binding::( + BindingOptions::new(), + Box::new(crate::provider::r#async::AsyncFactoryProvider::new( + crate::ptr::ThreadsafeFactoryPtr::new(factory_impl), + AsyncFactoryVariant::Normal, + )), + ); Ok(AsyncBindingWhenConfigurator::new(self.di_container)) } @@ -342,26 +329,23 @@ where /// # { /// # let mut di_container = AsyncDIContainer::new(); /// # - /// di_container - /// .bind::() - /// .to_default_factory(&|_| { - /// Box::new(|| { - /// let bar = TransientPtr::new(Bar { - /// num: 42, - /// some_str: "hello".to_string(), - /// }); + /// di_container.bind::().to_default_factory(&|_| { + /// Box::new(|| { + /// let bar = TransientPtr::new(Bar { + /// num: 42, + /// some_str: "hello".to_string(), + /// }); /// - /// bar as TransientPtr - /// }) + /// bar as TransientPtr /// }) - /// .await?; + /// })?; /// # /// # Ok(()) /// # } /// ``` #[cfg(feature = "factory")] #[cfg_attr(doc_cfg, doc(cfg(feature = "factory")))] - pub async fn to_default_factory( + pub fn to_default_factory( self, factory_func: &'static FactoryFunc, ) -> Result< @@ -380,7 +364,6 @@ where if self .di_container .has_binding::(BindingOptions::new()) - .await { return Err(AsyncBindingBuilderError::BindingAlreadyExists(type_name::< Interface, @@ -390,15 +373,13 @@ where let factory_impl = ThreadsafeCastableFactory::new(factory_func); - self.di_container - .set_binding::( - BindingOptions::new(), - Box::new(crate::provider::r#async::AsyncFactoryProvider::new( - crate::ptr::ThreadsafeFactoryPtr::new(factory_impl), - AsyncFactoryVariant::Default, - )), - ) - .await; + self.di_container.set_binding::( + BindingOptions::new(), + Box::new(crate::provider::r#async::AsyncFactoryProvider::new( + crate::ptr::ThreadsafeFactoryPtr::new(factory_impl), + AsyncFactoryVariant::Default, + )), + ); Ok(AsyncBindingWhenConfigurator::new(self.di_container)) } @@ -448,15 +429,14 @@ where /// bar as TransientPtr /// }) /// }) - /// }) - /// .await?; + /// })?; /// # /// # Ok(()) /// # } /// ``` #[cfg(feature = "factory")] #[cfg_attr(doc_cfg, doc(cfg(feature = "factory")))] - pub async fn to_async_default_factory( + pub fn to_async_default_factory( self, factory_func: &'static FactoryFunc, ) -> Result< @@ -475,7 +455,6 @@ where if self .di_container .has_binding::(BindingOptions::new()) - .await { return Err(AsyncBindingBuilderError::BindingAlreadyExists(type_name::< Interface, @@ -485,15 +464,13 @@ where let factory_impl = ThreadsafeCastableFactory::new(factory_func); - self.di_container - .set_binding::( - BindingOptions::new(), - Box::new(crate::provider::r#async::AsyncFactoryProvider::new( - crate::ptr::ThreadsafeFactoryPtr::new(factory_impl), - AsyncFactoryVariant::AsyncDefault, - )), - ) - .await; + self.di_container.set_binding::( + BindingOptions::new(), + Box::new(crate::provider::r#async::AsyncFactoryProvider::new( + crate::ptr::ThreadsafeFactoryPtr::new(factory_impl), + AsyncFactoryVariant::AsyncDefault, + )), + ); Ok(AsyncBindingWhenConfigurator::new(self.di_container)) } @@ -528,14 +505,11 @@ mod tests let binding_builder = AsyncBindingBuilder::::new( - &di_container_mock, + &mut di_container_mock, MockDependencyHistory::new, ); - binding_builder - .to::() - .await - .unwrap(); + binding_builder.to::().unwrap(); } #[tokio::test] @@ -570,7 +544,7 @@ mod tests .once(); let binding_builder = AsyncBindingBuilder::::new( - &di_container_mock, + &mut di_container_mock, MockDependencyHistory::new, ); @@ -583,7 +557,6 @@ mod tests user_manager }) }) - .await .unwrap(); } @@ -618,7 +591,7 @@ mod tests .once(); let binding_builder = AsyncBindingBuilder::::new( - &di_container_mock, + &mut di_container_mock, MockDependencyHistory::new, ); @@ -631,7 +604,6 @@ mod tests user_manager }) }) - .await .unwrap(); } @@ -662,7 +634,7 @@ mod tests let binding_builder = AsyncBindingBuilder::::new( - &di_container_mock, + &mut di_container_mock, MockDependencyHistory::new, ); @@ -675,7 +647,6 @@ mod tests user_manager }) }) - .await .unwrap(); } @@ -707,7 +678,7 @@ mod tests let binding_builder = AsyncBindingBuilder::::new( - &di_container_mock, + &mut di_container_mock, MockDependencyHistory::new, ); @@ -720,7 +691,6 @@ mod tests user_manager }) }) - .await .unwrap(); } } diff --git a/src/di_container/asynchronous/binding/scope_configurator.rs b/src/di_container/asynchronous/binding/scope_configurator.rs index b63e644..6f72cf0 100644 --- a/src/di_container/asynchronous/binding/scope_configurator.rs +++ b/src/di_container/asynchronous/binding/scope_configurator.rs @@ -18,7 +18,7 @@ where Interface: 'static + ?Sized + Send + Sync, Implementation: AsyncInjectable, { - di_container: &'di_container AsyncDIContainer, + di_container: &'di_container mut AsyncDIContainer, dependency_history_factory: fn() -> DependencyHistory, interface_phantom: PhantomData, @@ -32,7 +32,7 @@ where Implementation: AsyncInjectable, { pub(crate) fn new( - di_container: &'di_container AsyncDIContainer, + di_container: &'di_container mut AsyncDIContainer, dependency_history_factory: fn() -> DependencyHistory, ) -> Self { @@ -69,19 +69,18 @@ where /// /// di_container /// .bind::() - /// .to::() - /// .await? - /// .in_transient_scope() - /// .await; + /// .to::()? + /// .in_transient_scope(); /// # /// # Ok(()) /// # } /// ``` - pub async fn in_transient_scope( - self, + #[allow(clippy::must_use_candidate)] + pub fn in_transient_scope( + mut self, ) -> AsyncBindingWhenConfigurator<'di_container, Interface> { - self.set_in_transient_scope().await; + self.set_in_transient_scope(); AsyncBindingWhenConfigurator::new(self.di_container) } @@ -127,8 +126,7 @@ where /// /// di_container /// .bind::() - /// .to::() - /// .await? + /// .to::()? /// .in_singleton_scope() /// .await; /// @@ -168,26 +166,22 @@ where .map_err(AsyncBindingScopeConfiguratorError::SingletonResolveFailed)?, ); - self.di_container - .set_binding::( - BindingOptions::new(), - Box::new(AsyncSingletonProvider::new(singleton)), - ) - .await; + self.di_container.set_binding::( + BindingOptions::new(), + Box::new(AsyncSingletonProvider::new(singleton)), + ); Ok(AsyncBindingWhenConfigurator::new(self.di_container)) } - pub(crate) async fn set_in_transient_scope(&self) + pub(crate) fn set_in_transient_scope(&mut self) { - self.di_container - .set_binding::( - BindingOptions::new(), - Box::new( - AsyncTransientTypeProvider::::new(), - ), - ) - .await; + self.di_container.set_binding::( + BindingOptions::new(), + Box::new( + AsyncTransientTypeProvider::::new(), + ), + ); } } @@ -214,9 +208,9 @@ mod tests AsyncBindingScopeConfigurator::< dyn subjects_async::IUserManager, subjects_async::UserManager, - >::new(&di_container_mock, MockDependencyHistory::new); + >::new(&mut di_container_mock, MockDependencyHistory::new); - binding_scope_configurator.in_transient_scope().await; + binding_scope_configurator.in_transient_scope(); } #[tokio::test] @@ -234,7 +228,7 @@ mod tests AsyncBindingScopeConfigurator::< dyn subjects_async::IUserManager, subjects_async::UserManager, - >::new(&di_container_mock, MockDependencyHistory::new); + >::new(&mut di_container_mock, MockDependencyHistory::new); assert!(binding_scope_configurator .in_singleton_scope() diff --git a/src/di_container/asynchronous/binding/when_configurator.rs b/src/di_container/asynchronous/binding/when_configurator.rs index bc8e97f..5cec278 100644 --- a/src/di_container/asynchronous/binding/when_configurator.rs +++ b/src/di_container/asynchronous/binding/when_configurator.rs @@ -13,7 +13,7 @@ pub struct AsyncBindingWhenConfigurator<'di_container, Interface> where Interface: 'static + ?Sized + Send + Sync, { - di_container: &'di_container AsyncDIContainer, + di_container: &'di_container mut AsyncDIContainer, interface_phantom: PhantomData, } @@ -22,7 +22,7 @@ impl<'di_container, Interface> AsyncBindingWhenConfigurator<'di_container, Inter where Interface: 'static + ?Sized + Send + Sync, { - pub(crate) fn new(di_container: &'di_container AsyncDIContainer) -> Self + pub(crate) fn new(di_container: &'di_container mut AsyncDIContainer) -> Self { Self { di_container, @@ -56,17 +56,14 @@ where /// /// di_container /// .bind::() - /// .to::() - /// .await? + /// .to::()? /// .in_transient_scope() - /// .await - /// .when_named("Billy") - /// .await?; + /// .when_named("Billy")?; /// # /// # Ok(()) /// # } /// ``` - pub async fn when_named( + pub fn when_named( self, name: &'static str, ) -> Result<(), AsyncBindingWhenConfiguratorError> @@ -74,7 +71,6 @@ where let binding = self .di_container .remove_binding::(BindingOptions::new()) - .await .map_or_else( || { Err(AsyncBindingWhenConfiguratorError::BindingNotFound( @@ -85,8 +81,7 @@ where )?; self.di_container - .set_binding::(BindingOptions::new().name(name), binding) - .await; + .set_binding::(BindingOptions::new().name(name), binding); Ok(()) } @@ -121,11 +116,8 @@ mod tests let binding_when_configurator = AsyncBindingWhenConfigurator::< dyn subjects_async::INumber, - >::new(&di_container_mock); + >::new(&mut di_container_mock); - assert!(binding_when_configurator - .when_named("awesome") - .await - .is_ok()); + assert!(binding_when_configurator.when_named("awesome").is_ok()); } } diff --git a/src/di_container/asynchronous/mod.rs b/src/di_container/asynchronous/mod.rs index 13d4df0..7acdf4e 100644 --- a/src/di_container/asynchronous/mod.rs +++ b/src/di_container/asynchronous/mod.rs @@ -39,8 +39,7 @@ //! //! di_container //! .bind::() -//! .to::() -//! .await?; +//! .to::()?; //! //! let database_service = di_container //! .get::() @@ -53,8 +52,6 @@ use std::any::type_name; use std::sync::Arc; -use async_lock::Mutex; - use crate::di_container::asynchronous::binding::builder::AsyncBindingBuilder; use crate::di_container::binding_storage::DIContainerBindingStorage; use crate::di_container::BindingOptions; @@ -74,7 +71,7 @@ pub mod binding; #[derive(Default)] pub struct AsyncDIContainer { - binding_storage: Mutex>>, + binding_storage: DIContainerBindingStorage>, } impl AsyncDIContainer @@ -84,7 +81,7 @@ impl AsyncDIContainer pub fn new() -> Self { Self { - binding_storage: Mutex::new(DIContainerBindingStorage::new()), + binding_storage: DIContainerBindingStorage::new(), } } } @@ -113,7 +110,7 @@ impl AsyncDIContainer /// # async fn main() -> Result<(), Box> { /// let mut di_container = AsyncDIContainer::new(); /// - /// di_container.bind::().to::().await?; + /// di_container.bind::().to::()?; /// # /// # Ok(()) /// # } @@ -157,10 +154,7 @@ impl AsyncDIContainer /// # async fn main() -> Result<(), Box> { /// let mut di_container = AsyncDIContainer::new(); /// - /// di_container - /// .bind::() - /// .to::() - /// .await?; + /// di_container.bind::().to::()?; /// /// let device_manager = di_container.get::().await?.transient(); /// # @@ -206,12 +200,9 @@ impl AsyncDIContainer /// /// di_container /// .bind::() - /// .to::() - /// .await? + /// .to::()? /// .in_transient_scope() - /// .await - /// .when_named("usb") - /// .await; + /// .when_named("usb"); /// /// let device_manager = di_container /// .get_named::("usb") @@ -284,43 +275,32 @@ impl AsyncDIContainer self.handle_binding_providable(binding_providable).await } - async fn has_binding( - &self, - binding_options: BindingOptions<'static>, - ) -> bool + fn has_binding(&self, binding_options: BindingOptions<'static>) -> bool where Interface: ?Sized + 'static, { - self.binding_storage - .lock() - .await - .has::(binding_options) + self.binding_storage.has::(binding_options) } - async fn set_binding( - &self, + fn set_binding( + &mut self, binding_options: BindingOptions<'static>, provider: Box>, ) where Interface: 'static + ?Sized, { self.binding_storage - .lock() - .await .set::(binding_options, provider); } - async fn remove_binding( - &self, + fn remove_binding( + &mut self, binding_options: BindingOptions<'static>, ) -> Option>> where Interface: 'static + ?Sized, { - self.binding_storage - .lock() - .await - .remove::(binding_options) + self.binding_storage.remove::(binding_options) } } @@ -464,24 +444,19 @@ impl AsyncDIContainer where Interface: 'static + ?Sized + Send + Sync, { - let provider; - - { - let bindings_lock = self.binding_storage.lock().await; - - provider = bindings_lock - .get::(binding_options.clone()) - .map_or_else( - || { - Err(AsyncDIContainerError::BindingNotFound { - interface: type_name::(), - name: binding_options.name, - }) - }, - Ok, - )? - .clone(); - } + let provider = self + .binding_storage + .get::(binding_options.clone()) + .map_or_else( + || { + Err(AsyncDIContainerError::BindingNotFound { + interface: type_name::(), + name: binding_options.name, + }) + }, + Ok, + )? + .clone(); provider .provide(self, dependency_history) @@ -504,7 +479,7 @@ mod tests #[tokio::test] async fn can_get() { - let di_container = AsyncDIContainer::new(); + let mut di_container = AsyncDIContainer::new(); let mut mock_provider = MockAsyncProvider::new(); @@ -520,16 +495,12 @@ mod tests Box::new(inner_mock_provider) }); - { - di_container - .binding_storage - .lock() - .await - .set::( - BindingOptions::new(), - Box::new(mock_provider), - ); - } + di_container + .binding_storage + .set::( + BindingOptions::new(), + Box::new(mock_provider), + ); di_container .get::() @@ -542,7 +513,7 @@ mod tests #[tokio::test] async fn can_get_named() { - let di_container = AsyncDIContainer::new(); + let mut di_container = AsyncDIContainer::new(); let mut mock_provider = MockAsyncProvider::new(); @@ -558,16 +529,12 @@ mod tests Box::new(inner_mock_provider) }); - { - di_container - .binding_storage - .lock() - .await - .set::( - BindingOptions::new().name("special"), - Box::new(mock_provider), - ); - } + di_container + .binding_storage + .set::( + BindingOptions::new().name("special"), + Box::new(mock_provider), + ); di_container .get_named::("special") @@ -580,7 +547,7 @@ mod tests #[tokio::test] async fn can_get_singleton() { - let di_container = AsyncDIContainer::new(); + let mut di_container = AsyncDIContainer::new(); let mut mock_provider = MockAsyncProvider::new(); @@ -600,16 +567,12 @@ mod tests Box::new(inner_mock_provider) }); - { - di_container - .binding_storage - .lock() - .await - .set::( - BindingOptions::new(), - Box::new(mock_provider), - ); - } + di_container + .binding_storage + .set::( + BindingOptions::new(), + Box::new(mock_provider), + ); let first_number_rc = di_container .get::() @@ -633,7 +596,7 @@ mod tests #[tokio::test] async fn can_get_singleton_named() { - let di_container = AsyncDIContainer::new(); + let mut di_container = AsyncDIContainer::new(); let mut mock_provider = MockAsyncProvider::new(); @@ -653,16 +616,12 @@ mod tests Box::new(inner_mock_provider) }); - { - di_container - .binding_storage - .lock() - .await - .set::( - BindingOptions::new().name("cool"), - Box::new(mock_provider), - ); - } + di_container + .binding_storage + .set::( + BindingOptions::new().name("cool"), + Box::new(mock_provider), + ); let first_number_rc = di_container .get_named::("cool") @@ -730,7 +689,7 @@ mod tests type IUserManagerFactory = dyn Fn(Vec) -> TransientPtr + Send + Sync; - let di_container = AsyncDIContainer::new(); + let mut di_container = AsyncDIContainer::new(); let mut mock_provider = MockAsyncProvider::new(); @@ -757,8 +716,6 @@ mod tests di_container .binding_storage - .lock() - .await .set::(BindingOptions::new(), Box::new(mock_provider)); di_container @@ -816,7 +773,7 @@ mod tests type IUserManagerFactory = dyn Fn(Vec) -> TransientPtr + Send + Sync; - let di_container = AsyncDIContainer::new(); + let mut di_container = AsyncDIContainer::new(); let mut mock_provider = MockAsyncProvider::new(); @@ -841,16 +798,10 @@ mod tests Box::new(inner_mock_provider) }); - { - di_container - .binding_storage - .lock() - .await - .set::( - BindingOptions::new().name("special"), - Box::new(mock_provider), - ); - } + di_container.binding_storage.set::( + BindingOptions::new().name("special"), + Box::new(mock_provider), + ); di_container .get_named::("special") @@ -863,59 +814,43 @@ mod tests #[tokio::test] async fn has_binding_works() { - let di_container = AsyncDIContainer::new(); + let mut di_container = AsyncDIContainer::new(); // No binding is present yet assert!( - !di_container - .has_binding::(BindingOptions::new()) - .await + !di_container.has_binding::(BindingOptions::new()) ); - di_container - .binding_storage - .lock() - .await - .set::( - BindingOptions::new(), - Box::new(MockAsyncProvider::new()), - ); - - assert!( - di_container - .has_binding::(BindingOptions::new()) - .await + di_container.binding_storage.set::( + BindingOptions::new(), + Box::new(MockAsyncProvider::new()), ); + + assert!(di_container.has_binding::(BindingOptions::new())); } #[tokio::test] async fn set_binding_works() { - let di_container = AsyncDIContainer::new(); + let mut di_container = AsyncDIContainer::new(); - di_container - .set_binding::( - BindingOptions::new(), - Box::new(MockAsyncProvider::new()), - ) - .await; + di_container.set_binding::( + BindingOptions::new(), + Box::new(MockAsyncProvider::new()), + ); assert!(di_container .binding_storage - .lock() - .await .has::(BindingOptions::new())); } #[tokio::test] async fn remove_binding_works() { - let di_container = AsyncDIContainer::new(); + let mut di_container = AsyncDIContainer::new(); di_container .binding_storage - .lock() - .await .set::( BindingOptions::new(), Box::new(MockAsyncProvider::new()), @@ -925,7 +860,6 @@ mod tests // Formatting is weird without this comment di_container .remove_binding::(BindingOptions::new()) - .await .is_some() ); @@ -933,8 +867,6 @@ mod tests // Formatting is weird without this comment !di_container .binding_storage - .lock() - .await .has::(BindingOptions::new()) ); } -- cgit v1.2.3-18-g5258