1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-24 00:21:08 +01:00

better ergonomics

This commit is contained in:
Nikolay Kim 2018-08-09 17:25:23 -07:00
parent 26629aafa5
commit cc3fbd27e0

View File

@ -353,13 +353,16 @@ impl<T, E: Into<Error>> From<Result<T, E>> for AsyncResult<T> {
}
}
impl<T, E: Into<Error>> From<Result<Box<Future<Item = T, Error = Error>>, E>>
for AsyncResult<T>
impl<T, E> From<Result<Box<Future<Item = T, Error = E>>, E>> for AsyncResult<T>
where T: 'static,
E: Into<Error> + 'static
{
#[inline]
fn from(res: Result<Box<Future<Item = T, Error = Error>>, E>) -> Self {
fn from(res: Result<Box<Future<Item = T, Error = E>>, 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()))),
}
}