Skip to content

Commit f6cb0ed

Browse files
authored
use std::future::poll_fn (#194)
No need for this crate to maintain its own any longer. There was recent activity in the standard library around this, rust-lang/rust#102737 .
1 parent 002c94f commit f6cb0ed

File tree

5 files changed

+4
-33
lines changed

5 files changed

+4
-33
lines changed

src/future.rs

-29
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
use std::future::Future;
2-
use std::pin::Pin;
3-
use std::task::{Context, Poll};
4-
51
macro_rules! ready {
62
($e:expr $(,)?) => {
73
match $e {
@@ -10,28 +6,3 @@ macro_rules! ready {
106
}
117
};
128
}
13-
14-
#[must_use = "futures do nothing unless you `.await` or poll them"]
15-
pub(crate) struct PollFn<F> {
16-
f: F,
17-
}
18-
19-
impl<F> Unpin for PollFn<F> {}
20-
21-
pub(crate) fn poll_fn<T, F>(f: F) -> PollFn<F>
22-
where
23-
F: FnMut(&mut Context<'_>) -> Poll<T>,
24-
{
25-
PollFn { f }
26-
}
27-
28-
impl<T, F> Future for PollFn<F>
29-
where
30-
F: FnMut(&mut Context<'_>) -> Poll<T>,
31-
{
32-
type Output = T;
33-
34-
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<T> {
35-
(self.f)(cx)
36-
}
37-
}

src/io/shared_fd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::future::poll_fn;
21
use crate::io::Close;
2+
use std::future::poll_fn;
33

44
use std::cell::RefCell;
55
use std::os::unix::io::{FromRawFd, RawFd};

src/runtime/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl Runtime {
104104
tokio::pin!(future);
105105

106106
self.rt
107-
.block_on(self.local.run_until(crate::future::poll_fn(|cx| {
107+
.block_on(self.local.run_until(std::future::poll_fn(|cx| {
108108
// assert!(drive.as_mut().poll(cx).is_pending());
109109
future.as_mut().poll(cx)
110110
})))

tests/driver.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ async fn poll_once(future: impl std::future::Future) {
133133

134134
pin!(future);
135135

136-
future::poll_fn(|cx| {
136+
std::future::poll_fn(|cx| {
137137
assert!(future.as_mut().poll(cx).is_pending());
138138
Poll::Ready(())
139139
})

tests/fs_file.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ fn tempfile() -> NamedTempFile {
287287
}
288288

289289
async fn poll_once(future: impl std::future::Future) {
290-
use future::poll_fn;
290+
use std::future::poll_fn;
291291
// use std::future::Future;
292292
use std::task::Poll;
293293
use tokio::pin;

0 commit comments

Comments
 (0)