mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-24 00:21:08 +01:00
better ergonomics
This commit is contained in:
parent
26629aafa5
commit
cc3fbd27e0
@ -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>>
|
impl<T, E> From<Result<Box<Future<Item = T, Error = E>>, E>> for AsyncResult<T>
|
||||||
for AsyncResult<T>
|
where T: 'static,
|
||||||
|
E: Into<Error> + 'static
|
||||||
{
|
{
|
||||||
#[inline]
|
#[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 {
|
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()))),
|
Err(err) => AsyncResult(Some(AsyncResultItem::Err(err.into()))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user