aboutsummaryrefslogtreecommitdiff
path: root/src/di_container/blocking/binding
diff options
context:
space:
mode:
Diffstat (limited to 'src/di_container/blocking/binding')
-rw-r--r--src/di_container/blocking/binding/builder.rs12
-rw-r--r--src/di_container/blocking/binding/scope_configurator.rs16
-rw-r--r--src/di_container/blocking/binding/when_configurator.rs6
3 files changed, 19 insertions, 15 deletions
diff --git a/src/di_container/blocking/binding/builder.rs b/src/di_container/blocking/binding/builder.rs
index cd547d4..f322809 100644
--- a/src/di_container/blocking/binding/builder.rs
+++ b/src/di_container/blocking/binding/builder.rs
@@ -19,7 +19,7 @@ pub struct BindingBuilder<'di_container, Interface>
where
Interface: 'static + ?Sized,
{
- di_container: &'di_container DIContainer,
+ di_container: &'di_container mut DIContainer,
dependency_history_factory: fn() -> DependencyHistory,
interface_phantom: PhantomData<Interface>,
@@ -30,7 +30,7 @@ where
Interface: 'static + ?Sized,
{
pub(crate) fn new(
- di_container: &'di_container DIContainer,
+ di_container: &'di_container mut DIContainer,
dependency_history_factory: fn() -> DependencyHistory,
) -> Self
{
@@ -98,7 +98,7 @@ where
>()));
}
- let binding_scope_configurator = BindingScopeConfigurator::new(
+ let mut binding_scope_configurator = BindingScopeConfigurator::new(
self.di_container,
self.dependency_history_factory,
);
@@ -324,7 +324,7 @@ mod tests
.once();
let binding_builder = BindingBuilder::<dyn subjects::INumber>::new(
- &mock_di_container,
+ &mut mock_di_container,
MockDependencyHistory::new,
);
@@ -358,7 +358,7 @@ mod tests
.once();
let binding_builder = BindingBuilder::<IUserManagerFactory>::new(
- &mock_di_container,
+ &mut mock_di_container,
MockDependencyHistory::new,
);
@@ -400,7 +400,7 @@ mod tests
.once();
let binding_builder = BindingBuilder::<dyn subjects::IUserManager>::new(
- &mock_di_container,
+ &mut mock_di_container,
MockDependencyHistory::new,
);
diff --git a/src/di_container/blocking/binding/scope_configurator.rs b/src/di_container/blocking/binding/scope_configurator.rs
index ee935a5..ef7578b 100644
--- a/src/di_container/blocking/binding/scope_configurator.rs
+++ b/src/di_container/blocking/binding/scope_configurator.rs
@@ -18,7 +18,7 @@ where
Interface: 'static + ?Sized,
Implementation: Injectable<DIContainer>,
{
- di_container: &'di_container DIContainer,
+ di_container: &'di_container mut DIContainer,
dependency_history_factory: fn() -> DependencyHistory,
interface_phantom: PhantomData<Interface>,
@@ -32,7 +32,7 @@ where
Implementation: Injectable<DIContainer>,
{
pub(crate) fn new(
- di_container: &'di_container DIContainer,
+ di_container: &'di_container mut DIContainer,
dependency_history_factory: fn() -> DependencyHistory,
) -> Self
{
@@ -75,7 +75,9 @@ where
/// # }
/// ```
#[allow(clippy::must_use_candidate)]
- pub fn in_transient_scope(self) -> BindingWhenConfigurator<'di_container, Interface>
+ pub fn in_transient_scope(
+ mut self,
+ ) -> BindingWhenConfigurator<'di_container, Interface>
{
self.set_in_transient_scope();
@@ -161,7 +163,7 @@ where
Ok(BindingWhenConfigurator::new(self.di_container))
}
- pub(crate) fn set_in_transient_scope(&self)
+ pub(crate) fn set_in_transient_scope(&mut self)
{
self.di_container.set_binding::<Interface>(
BindingOptions::new(),
@@ -193,7 +195,8 @@ mod tests
dyn subjects::IUserManager,
subjects::UserManager,
>::new(
- &di_container_mock, MockDependencyHistory::new
+ &mut di_container_mock,
+ MockDependencyHistory::new,
);
binding_scope_configurator.in_transient_scope();
@@ -214,7 +217,8 @@ mod tests
dyn subjects::IUserManager,
subjects::UserManager,
>::new(
- &di_container_mock, MockDependencyHistory::new
+ &mut di_container_mock,
+ MockDependencyHistory::new,
);
assert!(binding_scope_configurator.in_singleton_scope().is_ok());
diff --git a/src/di_container/blocking/binding/when_configurator.rs b/src/di_container/blocking/binding/when_configurator.rs
index d23d213..e40f7b9 100644
--- a/src/di_container/blocking/binding/when_configurator.rs
+++ b/src/di_container/blocking/binding/when_configurator.rs
@@ -13,7 +13,7 @@ pub struct BindingWhenConfigurator<'di_container, Interface>
where
Interface: 'static + ?Sized,
{
- di_container: &'di_container DIContainer,
+ di_container: &'di_container mut DIContainer,
interface_phantom: PhantomData<Interface>,
}
@@ -22,7 +22,7 @@ impl<'di_container, Interface> BindingWhenConfigurator<'di_container, Interface>
where
Interface: 'static + ?Sized,
{
- pub(crate) fn new(di_container: &'di_container DIContainer) -> Self
+ pub(crate) fn new(di_container: &'di_container mut DIContainer) -> Self
{
Self {
di_container,
@@ -115,7 +115,7 @@ mod tests
.once();
let binding_when_configurator =
- BindingWhenConfigurator::<dyn subjects::INumber>::new(&di_container_mock);
+ BindingWhenConfigurator::<dyn subjects::INumber>::new(&mut di_container_mock);
assert!(binding_when_configurator.when_named("cool").is_ok());
}