aboutsummaryrefslogtreecommitdiff
path: root/src/di_container/asynchronous/binding/builder.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-01-19 20:21:17 +0100
committerHampusM <hampus@hampusmat.com>2023-01-19 20:21:17 +0100
commitbd10288adfaabdeb763fecb2f66d7dc4d35b37ee (patch)
tree697f66757382a974a964faac52bb147453ff819a /src/di_container/asynchronous/binding/builder.rs
parent45533a946c296a3a748a645fb80869f93ad7f09a (diff)
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
Diffstat (limited to 'src/di_container/asynchronous/binding/builder.rs')
-rw-r--r--src/di_container/asynchronous/binding/builder.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/di_container/asynchronous/binding/builder.rs b/src/di_container/asynchronous/binding/builder.rs
index 8ba5be3..b2d2b55 100644
--- a/src/di_container/asynchronous/binding/builder.rs
+++ b/src/di_container/asynchronous/binding/builder.rs
@@ -21,6 +21,7 @@ pub type BoxFn<Args, Return> = Box<(dyn Fn<Args, Output = Return> + Send + Sync)
/// Binding builder for type `Interface` inside a [`IAsyncDIContainer`].
///
/// [`IAsyncDIContainer`]: crate::di_container::asynchronous::IAsyncDIContainer
+#[must_use = "No binding will be created if you don't use the binding builder"]
pub struct AsyncBindingBuilder<Interface, DIContainerType, DependencyHistoryType>
where
Interface: 'static + ?Sized + Send + Sync,
@@ -96,7 +97,7 @@ where
///
/// [`IAsyncDIContainer`]: crate::di_container::asynchronous::IAsyncDIContainer
pub async fn to<Implementation>(
- &self,
+ self,
) -> Result<
AsyncBindingScopeConfigurator<
Interface,
@@ -121,7 +122,7 @@ where
self.dependency_history_factory,
);
- binding_scope_configurator.in_transient_scope().await;
+ binding_scope_configurator.set_in_transient_scope().await;
Ok(binding_scope_configurator)
}
@@ -178,7 +179,7 @@ where
#[cfg(feature = "factory")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "factory")))]
pub async fn to_factory<Args, Return, FactoryFunc>(
- &self,
+ self,
factory_func: &'static FactoryFunc,
) -> Result<
AsyncBindingWhenConfigurator<Interface, DIContainerType, DependencyHistoryType>,
@@ -271,7 +272,7 @@ where
#[cfg(feature = "factory")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "factory")))]
pub async fn to_async_factory<Args, Return, FactoryFunc>(
- &self,
+ self,
factory_func: &'static FactoryFunc,
) -> Result<
AsyncBindingWhenConfigurator<Interface, DIContainerType, DependencyHistoryType>,
@@ -364,7 +365,7 @@ where
#[cfg(feature = "factory")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "factory")))]
pub async fn to_default_factory<Return, FactoryFunc>(
- &self,
+ self,
factory_func: &'static FactoryFunc,
) -> Result<
AsyncBindingWhenConfigurator<Interface, DIContainerType, DependencyHistoryType>,
@@ -458,7 +459,7 @@ where
#[cfg(feature = "factory")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "factory")))]
pub async fn to_async_default_factory<Return, FactoryFunc>(
- &self,
+ self,
factory_func: &'static FactoryFunc,
) -> Result<
AsyncBindingWhenConfigurator<Interface, DIContainerType, DependencyHistoryType>,