aboutsummaryrefslogtreecommitdiff
path: root/src/provider/blocking.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-09-17 13:32:06 +0200
committerHampusM <hampus@hampusmat.com>2023-09-17 13:32:06 +0200
commita1ddd1bc6e1af0d98b87126d3e86da30bc1d3f1c (patch)
treed4a9cfd9e3970a955e27ac518a593f55e8ad8d9c /src/provider/blocking.rs
parent3e3a853615e97ee7c3aef09736eae8170c6fd78e (diff)
refactor!: make the blocking DI container not inside a Rc
BREAKING CHANGE: The blocking DI container is no longer inside of a Rc. This affects BindingBuilder, BindingScopeConfigurator, BindingWhenConfigurator & Injectable
Diffstat (limited to 'src/provider/blocking.rs')
-rw-r--r--src/provider/blocking.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/provider/blocking.rs b/src/provider/blocking.rs
index c719f59..1533f68 100644
--- a/src/provider/blocking.rs
+++ b/src/provider/blocking.rs
@@ -1,5 +1,4 @@
use std::marker::PhantomData;
-use std::rc::Rc;
use crate::errors::injectable::InjectableError;
use crate::interfaces::injectable::Injectable;
@@ -24,7 +23,7 @@ pub trait IProvider<DIContainerType>
{
fn provide(
&self,
- di_container: &Rc<DIContainerType>,
+ di_container: &DIContainerType,
dependency_history: DependencyHistory,
) -> Result<Providable<DIContainerType>, InjectableError>;
}
@@ -58,7 +57,7 @@ where
{
fn provide(
&self,
- di_container: &Rc<DIContainerType>,
+ di_container: &DIContainerType,
dependency_history: DependencyHistory,
) -> Result<Providable<DIContainerType>, InjectableError>
{
@@ -98,7 +97,7 @@ where
{
fn provide(
&self,
- _di_container: &Rc<DIContainerType>,
+ _di_container: &DIContainerType,
_dependency_history: DependencyHistory,
) -> Result<Providable<DIContainerType>, InjectableError>
{
@@ -133,7 +132,7 @@ impl<DIContainerType> IProvider<DIContainerType> for FactoryProvider
{
fn provide(
&self,
- _di_container: &Rc<DIContainerType>,
+ _di_container: &DIContainerType,
_dependency_history: DependencyHistory,
) -> Result<Providable<DIContainerType>, InjectableError>
{
@@ -168,7 +167,7 @@ mod tests
assert!(
matches!(
transient_type_provider
- .provide(&Rc::new(di_container), dependency_history_mock)?,
+ .provide(&di_container, dependency_history_mock)?,
Providable::Transient(_)
),
"The provided type is not transient"
@@ -190,7 +189,7 @@ mod tests
assert!(
matches!(
singleton_provider
- .provide(&Rc::new(di_container), MockDependencyHistory::new())?,
+ .provide(&di_container, MockDependencyHistory::new())?,
Providable::Singleton(_)
),
"The provided type is not a singleton"
@@ -215,7 +214,7 @@ mod tests
let default_factory_provider =
FactoryProvider::new(FactoryPtr::new(FooFactory), true);
- let di_container = Rc::new(MockDIContainer::new());
+ let di_container = MockDIContainer::new();
assert!(
matches!(