Skip to content

Commit

Permalink
switch to pin-project-lite
Browse files Browse the repository at this point in the history
  • Loading branch information
benjumanji committed Mar 13, 2020
1 parent 9f33272 commit 1e0b2b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ futures = { version = "0.3", optional = true }
nix = "0.14.0"
mio = { version = "0.6", optional = true }
tokio = { version = "0.2", optional = true, features = ["io-driver"] }
pin-utils = "0.1.0-alpha.4"
pin-project-lite = "0.1.4"
13 changes: 9 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extern crate futures;
extern crate mio;
extern crate nix;
#[cfg(feature = "use_tokio")]
extern crate pin_utils;
extern crate pin_project_lite;
#[cfg(feature = "use_tokio")]
extern crate tokio;

Expand All @@ -73,7 +73,7 @@ use mio::{Evented, Ready};
use nix::sys::epoll::*;
use nix::unistd::close;
#[cfg(feature = "use_tokio")]
use pin_utils::unsafe_pinned;
use pin_project_lite::pin_project;
#[cfg(feature = "use_tokio")]
use tokio::io::PollEvented;

Expand Down Expand Up @@ -683,7 +683,12 @@ impl Stream for PinStream {
}

#[cfg(feature = "use_tokio")]
pub struct PinValueStream { inner: PinStream }
pin_project! {
pub struct PinValueStream {
#[pin]
inner: PinStream
}
}

#[cfg(feature = "use_tokio")]
impl PinValueStream {
Expand All @@ -704,7 +709,7 @@ impl Stream for PinValueStream {
type Item = Result<u8>;

fn poll_next(mut self: SPin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
match self.as_mut().inner().poll_next(cx) {
match self.as_mut().inner.poll_next(cx) {
Poll::Ready(Some(res)) => {
match res {
Ok(_) => {
Expand Down

0 comments on commit 1e0b2b4

Please sign in to comment.