diff options
author | HampusM <hampus@hampusmat.com> | 2023-09-17 13:32:06 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2023-09-17 13:32:06 +0200 |
commit | a1ddd1bc6e1af0d98b87126d3e86da30bc1d3f1c (patch) | |
tree | d4a9cfd9e3970a955e27ac518a593f55e8ad8d9c /src/di_container/blocking/binding/when_configurator.rs | |
parent | 3e3a853615e97ee7c3aef09736eae8170c6fd78e (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/di_container/blocking/binding/when_configurator.rs')
-rw-r--r-- | src/di_container/blocking/binding/when_configurator.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/di_container/blocking/binding/when_configurator.rs b/src/di_container/blocking/binding/when_configurator.rs index 3d267b2..2a1af2c 100644 --- a/src/di_container/blocking/binding/when_configurator.rs +++ b/src/di_container/blocking/binding/when_configurator.rs @@ -1,7 +1,6 @@ //! When configurator for a binding for types inside of a [`DIContainer`]. use std::any::type_name; use std::marker::PhantomData; -use std::rc::Rc; use crate::di_container::BindingOptions; use crate::errors::di_container::BindingWhenConfiguratorError; @@ -10,20 +9,20 @@ use crate::util::use_double; use_double!(crate::di_container::blocking::DIContainer); /// When configurator for a binding for type `Interface` inside a [`DIContainer`]. -pub struct BindingWhenConfigurator<Interface> +pub struct BindingWhenConfigurator<'di_container, Interface> where Interface: 'static + ?Sized, { - di_container: Rc<DIContainer>, + di_container: &'di_container DIContainer, interface_phantom: PhantomData<Interface>, } -impl<Interface> BindingWhenConfigurator<Interface> +impl<'di_container, Interface> BindingWhenConfigurator<'di_container, Interface> where Interface: 'static + ?Sized, { - pub(crate) fn new(di_container: Rc<DIContainer>) -> Self + pub(crate) fn new(di_container: &'di_container DIContainer) -> Self { Self { di_container, @@ -88,9 +87,7 @@ mod tests .once(); let binding_when_configurator = - BindingWhenConfigurator::<dyn subjects::INumber>::new(Rc::new( - di_container_mock, - )); + BindingWhenConfigurator::<dyn subjects::INumber>::new(&di_container_mock); assert!(binding_when_configurator.when_named("cool").is_ok()); } |