From a1ddd1bc6e1af0d98b87126d3e86da30bc1d3f1c Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 17 Sep 2023 13:32:06 +0200 Subject: 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 --- src/provider/blocking.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/provider') 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 { fn provide( &self, - di_container: &Rc, + di_container: &DIContainerType, dependency_history: DependencyHistory, ) -> Result, InjectableError>; } @@ -58,7 +57,7 @@ where { fn provide( &self, - di_container: &Rc, + di_container: &DIContainerType, dependency_history: DependencyHistory, ) -> Result, InjectableError> { @@ -98,7 +97,7 @@ where { fn provide( &self, - _di_container: &Rc, + _di_container: &DIContainerType, _dependency_history: DependencyHistory, ) -> Result, InjectableError> { @@ -133,7 +132,7 @@ impl IProvider for FactoryProvider { fn provide( &self, - _di_container: &Rc, + _di_container: &DIContainerType, _dependency_history: DependencyHistory, ) -> Result, 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!( -- cgit v1.2.3-18-g5258