Error code E0727

A yield clause was used in an async context.

Erroneous code example:

#![feature(generators)]

fn main() {
    let generator = || {
        async {
            yield;
        }
    };
}
Run

Here, the yield keyword is used in an async block, which is not yet supported.

To fix this error, you have to move yield out of the async block:

#![feature(generators)]

fn main() {
    let generator = || {
        yield;
    };
}
Run

Back to list of error codes