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

@@ -1,6 +1,6 @@
use std::error::Error as StdError;
use pin_project::{pin_project, project};
use pin_project::pin_project;
use tokio::io::{AsyncRead, AsyncWrite};
use super::conn::{SpawnAll, UpgradeableConnection, Watcher};
@@ -18,7 +18,7 @@ pub struct Graceful<I, S, F, E> {
state: State<I, S, F, E>,
}
#[pin_project]
#[pin_project(project = StateProj)]
pub(super) enum State<I, S, F, E> {
Running {
drain: Option<(Signal, Watch)>,
@@ -58,14 +58,12 @@ where
{
type Output = crate::Result<()>;
#[project]
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
let mut me = self.project();
loop {
let next = {
#[project]
match me.state.as_mut().project() {
State::Running {
StateProj::Running {
drain,
spawn_all,
signal,
@@ -80,7 +78,7 @@ where
return spawn_all.poll_watch(cx, &GracefulWatcher(watch));
}
},
State::Draining(ref mut draining) => {
StateProj::Draining(ref mut draining) => {
return Pin::new(draining).poll(cx).map(Ok);
}
}