refactor(lib): Switch from pin-project to pin-project-lite

This commit is contained in:
Jonas Platte
2021-01-12 00:12:21 +01:00
committed by Sean McArthur
parent 9dff00425d
commit 43412a950f
14 changed files with 343 additions and 262 deletions

View File

@@ -9,7 +9,7 @@
#[cfg(feature = "stream")]
use futures_core::Stream;
#[cfg(feature = "stream")]
use pin_project::pin_project;
use pin_project_lite::pin_project;
use crate::common::{
task::{self, Poll},
@@ -86,8 +86,12 @@ pub fn from_stream<S, IO, E>(stream: S) -> impl Accept<Conn = IO, Error = E>
where
S: Stream<Item = Result<IO, E>>,
{
#[pin_project]
struct FromStream<S>(#[pin] S);
pin_project! {
struct FromStream<S> {
#[pin]
stream: S,
}
}
impl<S, IO, E> Accept for FromStream<S>
where
@@ -99,9 +103,9 @@ where
self: Pin<&mut Self>,
cx: &mut task::Context<'_>,
) -> Poll<Option<Result<Self::Conn, Self::Error>>> {
self.project().0.poll_next(cx)
self.project().stream.poll_next(cx)
}
}
FromStream(stream)
FromStream { stream }
}