async_coroutine 0.1.0

A coroutine implementation based on Rust's async/await syntax.
Documentation
  • Coverage
  • 100%
    17 out of 17 items documented1 out of 14 items with examples
  • Size
  • Source code size: 26.27 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • jannik4/bevy_capture
    18 1 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • jannik4

Async Coroutine

License Build Status crates.io docs.rs

This crate provides a coroutine implementation based on Rust's async/await syntax.

Usage

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"));