aboutsummaryrefslogtreecommitdiff
path: root/src/di_container/blocking/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/blocking/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/blocking/binding/builder.rs')
-rw-r--r--src/di_container/blocking/binding/builder.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/di_container/blocking/binding/builder.rs b/src/di_container/blocking/binding/builder.rs
index 65fa40f..27151d7 100644
--- a/src/di_container/blocking/binding/builder.rs
+++ b/src/di_container/blocking/binding/builder.rs
@@ -16,6 +16,7 @@ use crate::interfaces::injectable::Injectable;
/// Binding builder for type `Interface` inside a [`IDIContainer`].
///
/// [`IDIContainer`]: crate::di_container::blocking::IDIContainer
+#[must_use = "No binding will be created if you don't use the binding builder"]
pub struct BindingBuilder<Interface, DIContainerType, DependencyHistoryType>
where
Interface: 'static + ?Sized,
@@ -90,7 +91,7 @@ where
///
/// [`IDIContainer`]: crate::di_container::blocking::IDIContainer
pub fn to<Implementation>(
- &self,
+ self,
) -> Result<
BindingScopeConfigurator<
Interface,
@@ -117,7 +118,7 @@ where
self.dependency_history_factory,
);
- binding_scope_configurator.in_transient_scope();
+ binding_scope_configurator.set_in_transient_scope();
Ok(binding_scope_configurator)
}
@@ -191,7 +192,7 @@ where
#[cfg(feature = "factory")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "factory")))]
pub fn to_factory<Args, Return, Func>(
- &self,
+ self,
factory_func: &'static Func,
) -> Result<
BindingWhenConfigurator<Interface, DIContainerType, DependencyHistoryType>,
@@ -221,7 +222,7 @@ where
)),
);
- Ok(BindingWhenConfigurator::new(self.di_container.clone()))
+ Ok(BindingWhenConfigurator::new(self.di_container))
}
/// Creates a binding of type `Interface` to a factory that takes no arguments
@@ -280,7 +281,7 @@ where
#[cfg(feature = "factory")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "factory")))]
pub fn to_default_factory<Return, FactoryFunc>(
- &self,
+ self,
factory_func: &'static FactoryFunc,
) -> Result<
BindingWhenConfigurator<Interface, DIContainerType, DependencyHistoryType>,
@@ -313,7 +314,7 @@ where
)),
);
- Ok(BindingWhenConfigurator::new(self.di_container.clone()))
+ Ok(BindingWhenConfigurator::new(self.di_container))
}
}