2018-09-06 07:41:12 -05:00
|
|
|
// run-pass
|
|
|
|
|
2018-10-04 13:49:38 -05:00
|
|
|
#![feature(generators, generator_trait)]
|
2017-10-07 09:36:28 -05:00
|
|
|
|
2018-10-04 13:49:38 -05:00
|
|
|
use std::ops::{Generator, GeneratorState};
|
|
|
|
use std::pin::Pin;
|
2017-10-07 09:36:28 -05:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let _generator = || {
|
|
|
|
let mut sub_generator = || {
|
|
|
|
yield 2;
|
|
|
|
};
|
|
|
|
|
2020-01-25 13:03:10 -06:00
|
|
|
match Pin::new(&mut sub_generator).resume(()) {
|
2017-10-07 09:36:28 -05:00
|
|
|
GeneratorState::Yielded(x) => {
|
|
|
|
yield x;
|
|
|
|
}
|
|
|
|
_ => panic!(),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|