Home

Awesome

coroutine-rs

Build Status crates.io crates.io

Coroutine library in Rust

[dependencies]
coroutine = "0.8"

Usage

Basic usage of Coroutine

extern crate coroutine;

use std::usize;
use coroutine::asymmetric::Coroutine;

fn main() {
    let coro: Coroutine<i32> = Coroutine::spawn(|me,_| {
        for num in 0..10 {
            me.yield_with(num);
        }
        usize::MAX
    });

    for num in coro {
        println!("{}", num.unwrap());
    }
}

This program will print the following to the console

0
1
2
3
4
5
6
7
8
9
18446744073709551615

For more detail, please run cargo doc --open.

Goals

Notes

Thanks