Skip to content

Commit

Permalink
Remove unneeded dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
notgull committed Mar 15, 2023
1 parent 52cb4bf commit 5bd59cb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
2 changes: 0 additions & 2 deletions strategy/Cargo.toml
Expand Up @@ -13,8 +13,6 @@ exclude = ["/.*"]

[dependencies]
event-listener = { path = "..", version = "2", default-features = false }
pin-project-lite = "0.2.9"
pin-utils = "0.1.0"

[features]
default = ["std"]
Expand Down
41 changes: 18 additions & 23 deletions strategy/src/lib.rs
Expand Up @@ -74,9 +74,6 @@ use core::task::{Context, Poll};

use event_listener::EventListener;

#[doc(hidden)]
pub use pin_project_lite::pin_project;

/// A wrapper around an [`EventListenerFuture`] that can be easily exported for use.
///
/// This type implements [`Future`], has a `_new()` constructor, and a `wait()` method
Expand Down Expand Up @@ -140,12 +137,9 @@ macro_rules! easy_wrapper {
$(#[$wait_meta:meta])*
$wait_vis: vis wait();
) => {
$crate::pin_project! {
$(#[$meta])*
$vis struct $name {
#[pin]
_inner: $crate::FutureWrapper<$inner>
}
$(#[$meta])*
$vis struct $name {
_inner: $crate::FutureWrapper<$inner>
}

impl $name {
Expand All @@ -172,7 +166,10 @@ macro_rules! easy_wrapper {
self: ::core::pin::Pin<&mut Self>,
context: &mut ::core::task::Context<'_>
) -> ::core::task::Poll<Self::Output> {
self.project()._inner.poll(context)
// SAFETY: We are pinned, so our inner type must be pinned too.
unsafe {
self.map_unchecked_mut(|this| &mut this._inner).poll(context)
}
}
}
};
Expand Down Expand Up @@ -231,15 +228,12 @@ pub trait EventListenerFuture {
}
}

pin_project_lite::pin_project! {
/// A wrapper around an [`EventListenerFuture`] that implements [`Future`].
///
/// [`Future`]: core::future::Future
#[derive(Debug, Clone)]
pub struct FutureWrapper<F: ?Sized> {
#[pin]
inner: F,
}
/// A wrapper around an [`EventListenerFuture`] that implements [`Future`].
///
/// [`Future`]: core::future::Future
#[derive(Debug, Clone)]
pub struct FutureWrapper<F: ?Sized> {
inner: F,
}

impl<F: EventListenerFuture> FutureWrapper<F> {
Expand Down Expand Up @@ -272,13 +266,15 @@ impl<F: ?Sized> FutureWrapper<F> {
/// Get a pinned mutable reference to the inner future.
#[inline]
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut F> {
self.project().inner
// SAFETY: We are pinned, so our inner type must be pinned too.
unsafe { self.map_unchecked_mut(|this| &mut this.inner) }
}

/// Get a pinned reference to the inner future.
#[inline]
pub fn get_pin_ref(self: Pin<&Self>) -> Pin<&F> {
self.project_ref().inner
// SAFETY: We are pinned, so our inner type must be pinned too.
unsafe { self.map_unchecked(|this| &this.inner) }
}
}

Expand All @@ -294,8 +290,7 @@ impl<F: EventListenerFuture + ?Sized> Future for FutureWrapper<F> {

#[inline]
fn poll(self: Pin<&mut Self>, context: &mut Context<'_>) -> Poll<Self::Output> {
self.project()
.inner
self.get_pin_mut()
.poll_with_strategy(&mut NonBlocking::default(), context)
}
}
Expand Down

0 comments on commit 5bd59cb

Please sign in to comment.