aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-10-01 20:21:32 +0200
committerHampusM <hampus@hampusmat.com>2022-10-01 20:21:32 +0200
commitbfff8011fc7a55efa5e162ca938408636448cfbc (patch)
treeae35b1d5db8d5aba49920f68c52081785a77d05a /src
parent1b013d11f7d4ae58f95bff5a5bcc4b63e45f05df (diff)
refactor: shorten async binding builder trait bounds
Diffstat (limited to 'src')
-rw-r--r--src/async_di_container.rs26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/async_di_container.rs b/src/async_di_container.rs
index 894b707..caf7f22 100644
--- a/src/async_di_container.rs
+++ b/src/async_di_container.rs
@@ -81,6 +81,9 @@ use crate::provider::r#async::{
};
use crate::ptr::{SomeThreadsafePtr, ThreadsafeSingletonPtr, TransientPtr};
+/// Alias for a threadsafe boxed function.
+pub type BoxFn<Args, Return> = Box<(dyn Fn<Args, Output = Return> + Send + Sync)>;
+
/// When configurator for a binding for type 'Interface' inside a [`AsyncDIContainer`].
pub struct AsyncBindingWhenConfigurator<Interface>
where
@@ -269,11 +272,8 @@ where
Args: 'static,
Return: 'static + ?Sized,
Interface: Fn<Args, Output = Return> + Send + Sync,
- FactoryFunc: Fn<
- (Arc<AsyncDIContainer>,),
- Output = Box<(dyn Fn<Args, Output = Return> + Send + Sync)>,
- > + Send
- + Sync,
+ FactoryFunc:
+ Fn<(Arc<AsyncDIContainer>,), Output = BoxFn<Args, Return>> + Send + Sync,
{
use crate::provider::r#async::AsyncFactoryVariant;
@@ -320,11 +320,7 @@ where
Fn<Args, Output = crate::future::BoxFuture<'static, Return>> + Send + Sync,
FactoryFunc: Fn<
(Arc<AsyncDIContainer>,),
- Output = Box<
- (dyn Fn<Args, Output = crate::future::BoxFuture<'static, Return>>
- + Send
- + Sync),
- >,
+ Output = BoxFn<Args, crate::future::BoxFuture<'static, Return>>,
> + Send
+ Sync,
{
@@ -369,9 +365,7 @@ where
Return: 'static + ?Sized,
FactoryFunc: Fn<
(Arc<AsyncDIContainer>,),
- Output = Box<
- (dyn Fn<(), Output = crate::ptr::TransientPtr<Return>> + Send + Sync),
- >,
+ Output = BoxFn<(), crate::ptr::TransientPtr<Return>>,
> + Send
+ Sync,
{
@@ -417,11 +411,7 @@ where
Return: 'static + ?Sized,
FactoryFunc: Fn<
(Arc<AsyncDIContainer>,),
- Output = Box<
- (dyn Fn<(), Output = crate::future::BoxFuture<'static, Return>>
- + Send
- + Sync),
- >,
+ Output = BoxFn<(), crate::future::BoxFuture<'static, Return>>,
> + Send
+ Sync,
{