| Crates.io | async_coroutine |
| lib.rs | async_coroutine |
| version | 0.2.0 |
| created_at | 2025-07-08 21:26:46.65252+00 |
| updated_at | 2025-07-08 21:28:41.668968+00 |
| description | A coroutine implementation based on Rust's async/await syntax. |
| homepage | |
| repository | https://github.com/jannik4/async_coroutine |
| max_upload_size | |
| id | 1743618 |
| size | 26,747 |
This crate provides a coroutine implementation based on Rust's async/await syntax.
use async_coroutine::{Coroutine, State};
let mut co = Coroutine::new(|handle, value| async move {
assert_eq!(value, 1);
assert_eq!(handle.yield_(true).await, 2);
assert_eq!(handle.yield_(false).await, 3);
"Bye"
});
assert_eq!(co.resume_with(1), State::Yield(true));
assert_eq!(co.resume_with(2), State::Yield(false));
assert_eq!(co.resume_with(3), State::Complete("Bye"));