Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generator example does not compile #58195

Closed
diwic opened this issue Feb 5, 2019 · 2 comments
Closed

Generator example does not compile #58195

diwic opened this issue Feb 5, 2019 · 2 comments
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools

Comments

@diwic
Copy link
Contributor

diwic commented Feb 5, 2019

Here's an example:

https://doc.rust-lang.org/std/ops/trait.Generator.html

Trying to compile it with nightly@play.rust-lang.org (2019-02-04) yields (heh) the following errors:

error[E0599]: no method named `resume` found for type `[generator@src/main.rs:7:25: 10:6 _]` in the current scope
error[E0698]: type inside generator must be known in this context

For reference, here's the example I'm trying to compile:

#![allow(unused)]
#![feature(generators, generator_trait)]

use std::ops::{Generator, GeneratorState};

fn main() {
    let mut generator = || {
        yield 1;
        return "foo"
    };

    match unsafe { generator.resume() } {
        GeneratorState::Yielded(1) => {}
        _ => panic!("unexpected return from resume"),
    }
    match unsafe { generator.resume() } {
        GeneratorState::Complete("foo") => {}
        _ => panic!("unexpected return from resume"),
    }
}
@taiki-e
Copy link
Member

taiki-e commented Feb 5, 2019

The implementation of Generator has been changed in #55704.

The nightly document has the latest example: https://doc.rust-lang.org/nightly/std/ops/trait.Generator.html

@estebank estebank added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Feb 6, 2019
@diwic
Copy link
Contributor Author

diwic commented Feb 6, 2019

Thanks for the info! And sorry for the noise.

@diwic diwic closed this as completed Feb 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools
Projects
None yet
Development

No branches or pull requests

3 participants