25 releases

new 0.6.24 Feb 21, 2021
0.6.23 Oct 21, 2020
0.6.22 Sep 7, 2020
0.6.21 Jun 19, 2020
0.2.0 Nov 12, 2015

#13 in Data structures

Download history 15579/week @ 2020-11-04 16115/week @ 2020-11-11 16830/week @ 2020-11-18 14426/week @ 2020-11-25 19412/week @ 2020-12-02 18724/week @ 2020-12-09 18453/week @ 2020-12-16 12111/week @ 2020-12-23 14033/week @ 2020-12-30 16584/week @ 2021-01-06 15568/week @ 2021-01-13 14828/week @ 2021-01-20 13484/week @ 2021-01-27 11078/week @ 2021-02-03 9379/week @ 2021-02-10 23663/week @ 2021-02-17

63,787 downloads per month
Used in 32 crates (4 directly)

MIT/Apache

80KB
2K SLoC

Rust 1.5K SLoC // 0.2% comments Assembly 188 SLoC // 0.1% comments GNU Style Assembly 152 SLoC // 0.0% comments

Build Status Current Crates.io Version Document

Generator-rs

rust stackfull generator library

[dependencies]
generator = "0.6"

Usage

#[macro_use]
extern crate generator;
use generator::Gn;

fn main() {
    let g = Gn::new_scoped(|mut s| {
        let (mut a, mut b) = (0, 1);
        while b < 200 {
            std::mem::swap(&mut a, &mut b);
            b = a + b;
            s.yield_(b);
        }
        done!();
    });

    for i in g {
        println!("{}", i);
    }
}

Output

1
2
3
5
8
13
21
34
55
89
144
233

Goals

  • basic send/yield with message support
  • generator cancel support
  • yield_from support
  • panic inside generator support
  • stack size tune support
  • scoped static type support
  • basic coroutine interface support
  • stable rust support

based on this basic library

  • we can easily port python library based on generator into rust
  • coroutine framework running on multi thread

Notices

  • This crate supports below platforms, welcome to contribute with other arch and platforms

    • x86_64 Linux
    • x86_64 MacOs
    • x86_64 Windows

License

This project is licensed under either of the following, at your option:

Dependencies

~54–250KB