Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: How do ```async fn``` futures and ```#[coroutine]``` relate to each other?
Hello, everybody!
Recently I was experimenting with unstable #[coroutine]
feature that can be used to create functions (closures) that have two ways of returning -- a temporary return with yield x;
statement, after which it can be resumed, and with ordinary return x;
statement like any other function. I've tried to use it in some of my pet projects (they actively use various unstable nightly-only features). I wonder, how do coroutines relate to the similar feature in stable Rust -- async
/await
syntax? I've noted the following:
async
/await
is stable, #[coroutine]
and yield
statements are notasync
/await
and #[coroutine]
are available in core
, which means both can be used in no-std environments, such as an operating system kernel (I wonder, are there operating systems written in Rust that use async in the kernel?)Poll::Pending
like in CoroutineState::Yielded
1 post - 1 participant
🏷️ Rust_feed