refactor(lib): Remove uses of pin_project::project attribute (#2219)

pin-project will deprecate the project attribute due to some unfixable
limitations.

Refs: https://github.com/taiki-e/pin-project/issues/225
This commit is contained in:
Taiki Endo
2020-06-06 08:53:58 +09:00
committed by GitHub
parent 2354a7eec3
commit d5d09ed753
5 changed files with 21 additions and 31 deletions

View File

@@ -5,7 +5,7 @@ use std::time::Duration;
use h2::server::{Connection, Handshake, SendResponse};
use h2::Reason;
use pin_project::{pin_project, project};
use pin_project::pin_project;
use tokio::io::{AsyncRead, AsyncWrite};
use super::{decode_content_length, ping, PipeToSendStream, SendBuf};
@@ -326,7 +326,7 @@ where
state: H2StreamState<F, B>,
}
#[pin_project]
#[pin_project(project = H2StreamStateProj)]
enum H2StreamState<F, B>
where
B: HttpBody,
@@ -367,13 +367,11 @@ where
B::Error: Into<Box<dyn StdError + Send + Sync>>,
E: Into<Box<dyn StdError + Send + Sync>>,
{
#[project]
fn poll2(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<crate::Result<()>> {
let mut me = self.project();
loop {
#[project]
let next = match me.state.as_mut().project() {
H2StreamState::Service(h) => {
H2StreamStateProj::Service(h) => {
let res = match h.poll(cx) {
Poll::Ready(Ok(r)) => r,
Poll::Pending => {
@@ -417,7 +415,7 @@ where
return Poll::Ready(Ok(()));
}
}
H2StreamState::Body(pipe) => {
H2StreamStateProj::Body(pipe) => {
return pipe.poll(cx);
}
};