Use pin-project-lite instead of pin-project (#95)

This commit is contained in:
Sunli
2021-08-03 09:33:00 +02:00
committed by GitHub
parent ba74787532
commit be68227d73
12 changed files with 268 additions and 236 deletions
+7 -5
View File
@@ -9,10 +9,12 @@ macro_rules! opaque_future {
};
($(#[$m:meta])* pub type $name:ident<$($param:ident),*> = $actual:ty;) => {
#[pin_project::pin_project]
$(#[$m])*
pub struct $name<$($param),*>(#[pin] pub(crate) $actual)
where;
pin_project_lite::pin_project! {
$(#[$m])*
pub struct $name<$($param),*> {
#[pin] pub(crate) future: $actual,
}
}
impl<$($param),*> std::fmt::Debug for $name<$($param),*> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
@@ -27,7 +29,7 @@ macro_rules! opaque_future {
type Output = <$actual as std::future::Future>::Output;
#[inline]
fn poll(self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
self.project().0.poll(cx)
self.project().future.poll(cx)
}
}
};