mirror of
https://github.com/fafhrd91/actix-net
synced 2025-06-28 21:10:37 +02:00
Remove uses of pin_project::project attribute
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:
@ -81,7 +81,7 @@ where
|
||||
state: State<A, B>,
|
||||
}
|
||||
|
||||
#[pin_project::pin_project]
|
||||
#[pin_project::pin_project(project = StateProj)]
|
||||
enum State<A, B>
|
||||
where
|
||||
A: Service,
|
||||
@ -99,13 +99,11 @@ where
|
||||
{
|
||||
type Output = Result<B::Response, A::Error>;
|
||||
|
||||
#[pin_project::project]
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let mut this = self.as_mut().project();
|
||||
|
||||
#[project]
|
||||
match this.state.as_mut().project() {
|
||||
State::A(fut, b) => match fut.poll(cx)? {
|
||||
StateProj::A(fut, b) => match fut.poll(cx)? {
|
||||
Poll::Ready(res) => {
|
||||
let b = b.take().unwrap();
|
||||
this.state.set(State::Empty); // drop fut A
|
||||
@ -115,11 +113,11 @@ where
|
||||
}
|
||||
Poll::Pending => Poll::Pending,
|
||||
},
|
||||
State::B(fut) => fut.poll(cx).map(|r| {
|
||||
StateProj::B(fut) => fut.poll(cx).map(|r| {
|
||||
this.state.set(State::Empty);
|
||||
r
|
||||
}),
|
||||
State::Empty => panic!("future must not be polled after it returned `Poll::Ready`"),
|
||||
StateProj::Empty => panic!("future must not be polled after it returned `Poll::Ready`"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -179,7 +177,7 @@ where
|
||||
state: StateRC<A, B>,
|
||||
}
|
||||
|
||||
#[pin_project::pin_project]
|
||||
#[pin_project::pin_project(project = StateRCProj)]
|
||||
enum StateRC<A, B>
|
||||
where
|
||||
A: Service,
|
||||
@ -196,14 +194,12 @@ where
|
||||
B: Service<Request = A::Response, Error = A::Error>,
|
||||
{
|
||||
type Output = Result<B::Response, A::Error>;
|
||||
|
||||
#[pin_project::project]
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let mut this = self.as_mut().project();
|
||||
|
||||
#[project]
|
||||
|
||||
match this.state.as_mut().project() {
|
||||
StateRC::A(fut, b) => match fut.poll(cx)? {
|
||||
StateRCProj::A(fut, b) => match fut.poll(cx)? {
|
||||
Poll::Ready(res) => {
|
||||
let b = b.take().unwrap();
|
||||
this.state.set(StateRC::Empty); // drop fut A
|
||||
@ -213,11 +209,11 @@ where
|
||||
}
|
||||
Poll::Pending => Poll::Pending,
|
||||
},
|
||||
StateRC::B(fut) => fut.poll(cx).map(|r| {
|
||||
StateRCProj::B(fut) => fut.poll(cx).map(|r| {
|
||||
this.state.set(StateRC::Empty);
|
||||
r
|
||||
}),
|
||||
StateRC::Empty => panic!("future must not be polled after it returned `Poll::Ready`"),
|
||||
StateRCProj::Empty => panic!("future must not be polled after it returned `Poll::Ready`"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user