genawaiter 0.99.1

Stackless generators on stable Rust.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// These tests can't be parsed on non-nightly compilers, so move them to a
// separate file.

use crate::{ops::GeneratorState, sync::Gen};

#[test]
fn async_closure() {
    let mut gen = Gen::new(async move |co| {
        co.yield_(10).await;
        "done"
    });
    assert_eq!(gen.resume(), GeneratorState::Yielded(10));
    assert_eq!(gen.resume(), GeneratorState::Complete("done"));
}