From 31f7949ab380bcd0a0b754588e7d50284d2f5ae7 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 16 Sep 2023 15:40:45 +0200 Subject: refactor: move DI container get_binding_providable to other impl The get_binding_providable method doesn't need to be mocked so it should be moved to a non mocked impl --- src/di_container/blocking/mod.rs | 61 +++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 29 deletions(-) (limited to 'src/di_container/blocking') diff --git a/src/di_container/blocking/mod.rs b/src/di_container/blocking/mod.rs index 548f716..1ee0294 100644 --- a/src/di_container/blocking/mod.rs +++ b/src/di_container/blocking/mod.rs @@ -237,35 +237,6 @@ impl DIContainer } } - fn get_binding_providable( - self: &Rc, - binding_options: BindingOptionsWithLt, - dependency_history: DependencyHistory, - ) -> Result, DIContainerError> - where - Interface: 'static + ?Sized, - { - let name = binding_options.name; - - self.binding_storage - .borrow() - .get::(binding_options) - .map_or_else( - || { - Err(DIContainerError::BindingNotFound { - interface: type_name::(), - name: name.as_ref().map(ToString::to_string), - }) - }, - Ok, - )? - .provide(self, dependency_history) - .map_err(|err| DIContainerError::BindingResolveFailed { - reason: err, - interface: type_name::(), - }) - } - fn has_binding( self: &Rc, binding_options: BindingOptionsWithLt, @@ -303,6 +274,38 @@ impl DIContainer } } +impl DIContainer +{ + fn get_binding_providable( + self: &Rc, + binding_options: BindingOptionsWithLt, + dependency_history: DependencyHistory, + ) -> Result, DIContainerError> + where + Interface: 'static + ?Sized, + { + let name = binding_options.name; + + self.binding_storage + .borrow() + .get::(binding_options) + .map_or_else( + || { + Err(DIContainerError::BindingNotFound { + interface: type_name::(), + name: name.as_ref().map(ToString::to_string), + }) + }, + Ok, + )? + .provide(self, dependency_history) + .map_err(|err| DIContainerError::BindingResolveFailed { + reason: err, + interface: type_name::(), + }) + } +} + #[cfg(test)] mod tests { -- cgit v1.2.3-18-g5258