Skip to content
Please note that GitHub no longer supports Internet Explorer.

We recommend upgrading to the latest Microsoft Edge, Google Chrome, or Firefox.

Learn more
Stackless generators on stable Rust.
Rust
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows Test all combinations of features Jan 23, 2020
genawaiter-proc-macro fn like macro now accepts block not closure Jan 15, 2020
src fn like macro now accepts block not closure Jan 15, 2020
tests fn like macro now accepts block not closure Jan 15, 2020
.editorconfig first blood Nov 3, 2019
.gitignore init WIP add proc_macro generator generator Dec 8, 2019
.pre-commit-config.yaml Test all combinations of features Jan 23, 2020
CHANGELOG.md Update changelog Nov 26, 2019
Cargo.lock visitor pattern done, doc and refine Dec 8, 2019
Cargo.toml add #[must_use for clippy], remove mod files, move fn arg insert to v… Dec 24, 2019
README-crates-io.md
README.md Update the docs Nov 11, 2019
rustfmt.toml first blood Nov 3, 2019

README.md

genawaiter

crate-badge docs-badge ci-badge

This crate implements stackless generators (aka coroutines) in stable Rust. Instead of using yield, which won't be stabilized anytime soon, you use async/await, which is stable today.

Features:

  • safe
  • allocation-free
  • supports resume arguments
  • no dependencies

Example:

let generator = Gen::new(|co| async move {
    let mut n = 1;
    while n < 10 {
        // Suspend a function at any point with a value.
        co.yield_(n).await;
        n += 2;
    }
});

// Generators can be used as ordinary iterators.
for num in generator {
    println!("{}", num);
}

Result:

1
3
5
7
9

See the docs for more.

Development

Install prerequisites

Install the pre-commit hook

pre-commit install

This installs a Git hook that runs a quick sanity check before every commit.

Run the app

cargo run

Run the tests

cargo test
You can’t perform that action at this time.