From 1d9c42c309097a857a39afca2ff2fb43c310859a Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Fri, 1 Nov 2019 21:51:09 +0600 Subject: [PATCH] Fix --- src/dispatching/dispatchers/filter/error_policy.rs | 10 +++------- src/dispatching/dispatchers/filter/mod.rs | 4 ++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/dispatching/dispatchers/filter/error_policy.rs b/src/dispatching/dispatchers/filter/error_policy.rs index d80e2389..d3760c41 100644 --- a/src/dispatching/dispatchers/filter/error_policy.rs +++ b/src/dispatching/dispatchers/filter/error_policy.rs @@ -4,10 +4,8 @@ use async_trait::async_trait; /// Implementors of this trait are treated as error-handlers. #[async_trait] -pub trait ErrorPolicy { - type Error; - - async fn handle_error(&mut self, error: Self::Error); +pub trait ErrorPolicy { + async fn handle_error(&mut self, error: E); } /// A convenient structure with an error-handling closure. Implements @@ -15,14 +13,12 @@ pub trait ErrorPolicy { pub struct FnErrorPolicy(pub F); #[async_trait] -impl ErrorPolicy for FnErrorPolicy +impl ErrorPolicy for FnErrorPolicy where F: FnMut(E) -> Fut + Send, Fut: Future, E: Send, { - type Error = E; - async fn handle_error(&mut self, error: E) { self.0(error); } diff --git a/src/dispatching/dispatchers/filter/mod.rs b/src/dispatching/dispatchers/filter/mod.rs index fce18a5d..c4203747 100644 --- a/src/dispatching/dispatchers/filter/mod.rs +++ b/src/dispatching/dispatchers/filter/mod.rs @@ -82,7 +82,7 @@ pub struct FilterDispatcher<'a, E, Ep> { impl<'a, E, Ep> FilterDispatcher<'a, E, Ep> where - Ep: ErrorPolicy, + Ep: ErrorPolicy, E: std::fmt::Debug, // TODO: Is this really necessary? { pub fn new(error_policy: Ep) -> Self { @@ -269,7 +269,7 @@ impl<'a, U, E, Ep> Dispatcher<'a, U> for FilterDispatcher<'a, E, Ep> where E: std::fmt::Debug, U: Updater + 'a, - Ep: ErrorPolicy, + Ep: ErrorPolicy, { async fn dispatch(&'a mut self, updater: U) { FilterDispatcher::dispatch(self, updater).await