Closed
Description
original issue: smol-rs/smol#157
/// Pins a future and then polls it.
fn poll_future<T>(cx: &mut Context<'_>, fut: impl Future<Output = T>) -> Poll<T> {
futures_util::pin_mut!(fut);
fut.poll(cx)
}
This function is really useful in providing a bridge between simple async
functions and poll_*
methods; but appropriate documentation would need to be added, because it has the limitation that all state of the Future
, which is only saved in the Future
itself, and not via &mut
bindings / etc., is lost after each yield, and the async
fn should be designed to handle that case (e.g. be reentrant without strict dependency on local state; caching is ok, but external state shouldn't be corrupted if the Future
yields and resets).
Metadata
Metadata
Assignees
Labels
No labels