mirror of
https://github.com/async-rs/async-std.git
synced 2025-04-15 21:06:44 +00:00
feat: no to_std future::poll_fn
This commit is contained in:
parent
da23d16019
commit
94a6ff34c2
1 changed files with 9 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
use std::pin::Pin;
|
||||
use std::future::Future;
|
||||
use core::future::Future;
|
||||
use core::pin::Pin;
|
||||
|
||||
use crate::task::{Context, Poll};
|
||||
|
||||
|
@ -23,15 +23,18 @@ use crate::task::{Context, Poll};
|
|||
/// #
|
||||
/// # })
|
||||
/// ```
|
||||
pub async fn poll_fn<F, T>(f: F) -> T
|
||||
pub fn poll_fn<F, T>(f: F) -> PollFn<F>
|
||||
where
|
||||
F: FnMut(&mut Context<'_>) -> Poll<T>,
|
||||
{
|
||||
let fut = PollFn { f };
|
||||
fut.await
|
||||
PollFn { f }
|
||||
}
|
||||
|
||||
struct PollFn<F> {
|
||||
/// This future is constructed by the [`poll_fn`] function.
|
||||
///
|
||||
/// [`poll_fn`]: fn.poll_fn.html
|
||||
#[derive(Debug)]
|
||||
pub struct PollFn<F> {
|
||||
f: F,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue