Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 94a6ff3

Browse files
committed
feat: no to_std future::poll_fn
1 parent da23d16 commit 94a6ff3

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

‎src/future/poll_fn.rs

Lines changed: 9 additions & 6 deletions
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 asyncfn 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)

AltStyle によって変換されたページ (->オリジナル) /