From 7bed48c852a741df5a14359916faf21d90d39814 Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 31 Aug 2023 19:19:06 +0200 Subject: refactor: pass around BindingOptions instead of name --- src/di_container/asynchronous/binding/when_configurator.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/di_container/asynchronous/binding/when_configurator.rs') diff --git a/src/di_container/asynchronous/binding/when_configurator.rs b/src/di_container/asynchronous/binding/when_configurator.rs index d08239e..4521178 100644 --- a/src/di_container/asynchronous/binding/when_configurator.rs +++ b/src/di_container/asynchronous/binding/when_configurator.rs @@ -6,6 +6,7 @@ use std::marker::PhantomData; use std::sync::Arc; use crate::di_container::asynchronous::IAsyncDIContainer; +use crate::di_container::BindingOptions; use crate::errors::async_di_container::AsyncBindingWhenConfiguratorError; /// When configurator for a binding for type `Interface` inside a [`IAsyncDIContainer`]. @@ -45,7 +46,7 @@ where { let binding = self .di_container - .remove_binding::(None) + .remove_binding::(BindingOptions::new()) .await .map_or_else( || { @@ -57,7 +58,7 @@ where )?; self.di_container - .set_binding::(Some(name), binding) + .set_binding::(BindingOptions::new().name(name), binding) .await; Ok(()) @@ -81,13 +82,13 @@ mod tests di_container_mock .expect_remove_binding::() - .with(eq(None)) + .with(eq(BindingOptions::new())) .return_once(|_name| Some(Box::new(MockIAsyncProvider::new()))) .once(); di_container_mock .expect_set_binding::() - .withf(|name, _provider| name == &Some("awesome")) + .withf(|binding_options, _provider| binding_options.name == Some("awesome")) .return_once(|_name, _provider| ()) .once(); -- cgit v1.2.3-18-g5258