Skip to content

Commit 28c0b31

Browse files
committed
feat: no to_std future::poll_fn
1 parent b4fc5ca commit 28c0b31

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/future/poll_fn.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use std::pin::Pin;
2-
use std::future::Future;
1+
use core::future::Future;
2+
use core::pin::Pin;
33

44
use crate::task::{Context, Poll};
55

@@ -23,15 +23,18 @@ use crate::task::{Context, Poll};
2323
/// #
2424
/// # })
2525
/// ```
26-
pub async fn poll_fn<F, T>(f: F) -> T
26+
pub fn poll_fn<F, T>(f: F) -> PollFn<F>
2727
where
2828
F: FnMut(&mut Context<'_>) -> Poll<T>,
2929
{
30-
let fut = PollFn { f };
31-
fut.await
30+
PollFn { f }
3231
}
3332

34-
struct PollFn<F> {
33+
/// This future is constructed by the [`poll_fn`] function.
34+
///
35+
/// [`poll_fn`]: fn.poll_fn.html
36+
#[derive(Debug)]
37+
pub struct PollFn<F> {
3538
f: F,
3639
}
3740

0 commit comments

Comments
 (0)