From bfff8011fc7a55efa5e162ca938408636448cfbc Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 1 Oct 2022 20:21:32 +0200 Subject: refactor: shorten async binding builder trait bounds --- src/async_di_container.rs | 26 ++++++++------------------ 1 file 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 = Box<(dyn Fn + Send + Sync)>; + /// When configurator for a binding for type 'Interface' inside a [`AsyncDIContainer`]. pub struct AsyncBindingWhenConfigurator where @@ -269,11 +272,8 @@ where Args: 'static, Return: 'static + ?Sized, Interface: Fn + Send + Sync, - FactoryFunc: Fn< - (Arc,), - Output = Box<(dyn Fn + Send + Sync)>, - > + Send - + Sync, + FactoryFunc: + Fn<(Arc,), Output = BoxFn> + Send + Sync, { use crate::provider::r#async::AsyncFactoryVariant; @@ -320,11 +320,7 @@ where Fn> + Send + Sync, FactoryFunc: Fn< (Arc,), - Output = Box< - (dyn Fn> - + Send - + Sync), - >, + Output = BoxFn>, > + Send + Sync, { @@ -369,9 +365,7 @@ where Return: 'static + ?Sized, FactoryFunc: Fn< (Arc,), - Output = Box< - (dyn Fn<(), Output = crate::ptr::TransientPtr> + Send + Sync), - >, + Output = BoxFn<(), crate::ptr::TransientPtr>, > + Send + Sync, { @@ -417,11 +411,7 @@ where Return: 'static + ?Sized, FactoryFunc: Fn< (Arc,), - Output = Box< - (dyn Fn<(), Output = crate::future::BoxFuture<'static, Return>> - + Send - + Sync), - >, + Output = BoxFn<(), crate::future::BoxFuture<'static, Return>>, > + Send + Sync, { -- cgit v1.2.3-18-g5258