From d46181de1c19328ff8f3f6a12784cf14c53e9e71 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 15 Sep 2024 23:33:33 +0200 Subject: refactor!: rename to_*default_factory functions to to_*dynamic_value BREAKING CHANGE: The functions to_default_factory and to_async_default_factory have been renamed to to_dynamic_value and to_async_dynamic_value, respectively --- src/di_container/asynchronous.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/di_container/asynchronous.rs') diff --git a/src/di_container/asynchronous.rs b/src/di_container/asynchronous.rs index c6308e6..a338c0a 100644 --- a/src/di_container/asynchronous.rs +++ b/src/di_container/asynchronous.rs @@ -371,20 +371,20 @@ impl AsyncDIContainer use crate::castable_function::threadsafe::ThreadsafeCastableFunction; use crate::ptr::TransientPtr; - type DefaultFactoryFn = ThreadsafeCastableFunction< + type Func = ThreadsafeCastableFunction< dyn Fn() -> TransientPtr + Send + Sync, AsyncDIContainer, >; - let default_factory = func_bound + let dynamic_val_func = func_bound .as_any() - .downcast_ref::>() + .downcast_ref::>() .ok_or_else(|| AsyncDIContainerError::CastFailed { - interface: type_name::>(), - binding_kind: "default factory", + interface: type_name::>(), + binding_kind: "dynamic value func", })?; - Ok(SomePtr::Transient(default_factory.call(self)())) + Ok(SomePtr::Transient(dynamic_val_func.call(self)())) } #[cfg(feature = "factory")] AsyncProvidable::Function( @@ -395,22 +395,24 @@ impl AsyncDIContainer use crate::future::BoxFuture; use crate::ptr::TransientPtr; - type AsyncDefaultFactoryFn = ThreadsafeCastableFunction< + type Func = ThreadsafeCastableFunction< dyn Fn<(), Output = BoxFuture<'static, TransientPtr>> + Send + Sync, AsyncDIContainer, >; - let async_default_factory = func_bound + let async_dynamic_value_func = func_bound .as_any() - .downcast_ref::>() + .downcast_ref::>() .ok_or_else(|| AsyncDIContainerError::CastFailed { - interface: type_name::>(), - binding_kind: "async default factory", + interface: type_name::>(), + binding_kind: "async dynamic value function", })?; - Ok(SomePtr::Transient(async_default_factory.call(self)().await)) + Ok(SomePtr::Transient( + async_dynamic_value_func.call(self)().await, + )) } } } -- cgit v1.2.3-18-g5258