From cc3fbd27e05723c5004ae302263ad78fc2a53d39 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Thu, 9 Aug 2018 17:25:23 -0700 Subject: [PATCH] better ergonomics --- src/handler.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/handler.rs b/src/handler.rs index 3ac0c2ab2..661cd0285 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -353,13 +353,16 @@ impl> From> for AsyncResult { } } -impl> From>, E>> - for AsyncResult +impl From>, E>> for AsyncResult +where T: 'static, + E: Into + 'static { #[inline] - fn from(res: Result>, E>) -> Self { + fn from(res: Result>, E>) -> Self { match res { - Ok(fut) => AsyncResult(Some(AsyncResultItem::Future(fut))), + Ok(fut) => AsyncResult( + Some(AsyncResultItem::Future( + Box::new(fut.map_err(|e| e.into()))))), Err(err) => AsyncResult(Some(AsyncResultItem::Err(err.into()))), } }