Skip to content

Commit

Permalink
Remove uses of pin_project::project attribute
Browse files Browse the repository at this point in the history
pin-project will deprecate the project attribute due to some unfixable
limitations.

Refs: taiki-e/pin-project#225
  • Loading branch information
taiki-e authored and tikue committed Jun 6, 2020
1 parent 617daeb commit f0322fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
3 changes: 1 addition & 2 deletions tarpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fnv = "1.0"
futures = "0.3"
humantime = "1.0"
log = "0.4"
pin-project = "0.4"
pin-project = "0.4.17"
rand = "0.7"
tokio = { version = "0.2", features = ["time"] }
serde = { optional = true, version = "1.0", features = ["derive"] }
Expand Down Expand Up @@ -60,4 +60,3 @@ required-features = ["full"]
[[example]]
name = "pubsub"
required-features = ["full"]

12 changes: 5 additions & 7 deletions tarpc/src/rpc/client/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use futures::{
task::*,
};
use log::{debug, info, trace};
use pin_project::{pin_project, pinned_drop, project};
use pin_project::{pin_project, pinned_drop};
use std::{
io,
pin::Pin,
Expand Down Expand Up @@ -628,7 +628,7 @@ where
}
}

#[pin_project]
#[pin_project(project = TryChainProj)]
#[must_use = "futures do nothing unless polled"]
#[derive(Debug)]
enum TryChain<Fut1, Fut2> {
Expand All @@ -654,7 +654,6 @@ where
TryChain::First(fut1)
}

#[project]
fn poll<F>(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
Expand All @@ -666,20 +665,19 @@ where
let mut f = Some(f);

loop {
#[project]
let output = match self.as_mut().project() {
TryChain::First(fut1) => {
TryChainProj::First(fut1) => {
// Poll the first future
match fut1.try_poll(cx) {
Poll::Pending => return Poll::Pending,
Poll::Ready(output) => output,
}
}
TryChain::Second(fut2) => {
TryChainProj::Second(fut2) => {
// Poll the second future
return fut2.try_poll(cx);
}
TryChain::Empty => {
TryChainProj::Empty => {
panic!("future must not be polled after it returned `Poll::Ready`");
}
};
Expand Down

0 comments on commit f0322fb

Please sign in to comment.