mirror of https://github.com/fafhrd91/actix-web
use ready macro
This commit is contained in:
parent
936e12cc9d
commit
13aa374703
|
@ -5,6 +5,7 @@ use std::task::{Context, Poll};
|
||||||
|
|
||||||
use actix_http::error::Error;
|
use actix_http::error::Error;
|
||||||
use futures_util::future::{ready, Ready};
|
use futures_util::future::{ready, Ready};
|
||||||
|
use futures_util::ready;
|
||||||
|
|
||||||
use crate::dev::Payload;
|
use crate::dev::Payload;
|
||||||
use crate::request::HttpRequest;
|
use crate::request::HttpRequest;
|
||||||
|
@ -121,13 +122,14 @@ where
|
||||||
type Output = Result<Option<T>, Error>;
|
type Output = Result<Option<T>, Error>;
|
||||||
|
|
||||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
match self.project().fut.poll(cx) {
|
let this = self.project();
|
||||||
Poll::Ready(Ok(t)) => Poll::Ready(Ok(Some(t))),
|
let res = ready!(this.fut.poll(cx));
|
||||||
Poll::Ready(Err(e)) => {
|
match res {
|
||||||
|
Ok(t) => Poll::Ready(Ok(Some(t))),
|
||||||
|
Err(e) => {
|
||||||
log::debug!("Error for Option<T> extractor: {}", e.into());
|
log::debug!("Error for Option<T> extractor: {}", e.into());
|
||||||
Poll::Ready(Ok(None))
|
Poll::Ready(Ok(None))
|
||||||
}
|
}
|
||||||
Poll::Pending => Poll::Pending,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,11 +211,9 @@ where
|
||||||
type Output = Result<Result<T, E>, Error>;
|
type Output = Result<Result<T, E>, Error>;
|
||||||
|
|
||||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
match self.project().fut.poll(cx) {
|
let this = self.project();
|
||||||
Poll::Ready(Ok(t)) => Poll::Ready(Ok(Ok(t))),
|
let res = ready!(this.fut.poll(cx));
|
||||||
Poll::Ready(Err(e)) => Poll::Ready(Ok(Err(e))),
|
Poll::Ready(Ok(res))
|
||||||
Poll::Pending => Poll::Pending,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue