From bd10288adfaabdeb763fecb2f66d7dc4d35b37ee Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 19 Jan 2023 20:21:17 +0100 Subject: refactor!: make binding builder & configurator methods take self ownership BREAKING CHANGE: The methods of BindingBuilder, AsyncBuilder, BindingScopeConfigurator, AsyncBindingScopeConfigurator, BindingWhenConfigurator, AsyncBindingWhenConfigurator now take ownership of self --- .../asynchronous/binding/scope_configurator.rs | 29 +++++++++++++--------- 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'src/di_container/asynchronous/binding/scope_configurator.rs') diff --git a/src/di_container/asynchronous/binding/scope_configurator.rs b/src/di_container/asynchronous/binding/scope_configurator.rs index b5923ec..2271a16 100644 --- a/src/di_container/asynchronous/binding/scope_configurator.rs +++ b/src/di_container/asynchronous/binding/scope_configurator.rs @@ -63,19 +63,10 @@ where /// /// This is the default. pub async fn in_transient_scope( - &self, + self, ) -> AsyncBindingWhenConfigurator { - self.di_container - .set_binding::( - None, - Box::new(AsyncTransientTypeProvider::< - Implementation, - DIContainerType, - DependencyHistoryType, - >::new()), - ) - .await; + self.set_in_transient_scope().await; AsyncBindingWhenConfigurator::new(self.di_container.clone()) } @@ -85,7 +76,7 @@ where /// # Errors /// Will return Err if resolving the implementation fails. pub async fn in_singleton_scope( - &self, + self, ) -> Result< AsyncBindingWhenConfigurator, AsyncBindingScopeConfiguratorError, @@ -110,6 +101,20 @@ where Ok(AsyncBindingWhenConfigurator::new(self.di_container.clone())) } + + pub(crate) async fn set_in_transient_scope(&self) + { + self.di_container + .set_binding::( + None, + Box::new(AsyncTransientTypeProvider::< + Implementation, + DIContainerType, + DependencyHistoryType, + >::new()), + ) + .await; + } } #[cfg(test)] -- cgit v1.2.3-18-g5258