2018-09-06 07:41:12 -05:00
|
|
|
// run-pass
|
|
|
|
|
2017-08-09 15:56:19 -05:00
|
|
|
// aux-build:xcrate.rs
|
|
|
|
|
2017-07-07 18:12:44 -05:00
|
|
|
#![feature(generators, generator_trait)]
|
|
|
|
|
2017-08-09 15:56:19 -05:00
|
|
|
extern crate xcrate;
|
|
|
|
|
|
|
|
use std::ops::{GeneratorState, Generator};
|
2018-10-04 13:49:38 -05:00
|
|
|
use std::pin::Pin;
|
2017-07-07 18:12:44 -05:00
|
|
|
|
|
|
|
fn main() {
|
2017-08-09 15:56:19 -05:00
|
|
|
let mut foo = xcrate::foo();
|
2017-07-07 18:12:44 -05:00
|
|
|
|
2020-01-25 13:03:10 -06:00
|
|
|
match Pin::new(&mut foo).resume(()) {
|
2017-08-09 15:56:19 -05:00
|
|
|
GeneratorState::Complete(()) => {}
|
|
|
|
s => panic!("bad state: {:?}", s),
|
|
|
|
}
|
2017-08-09 18:38:05 -05:00
|
|
|
|
|
|
|
let mut foo = xcrate::bar(3);
|
|
|
|
|
2020-01-25 13:03:10 -06:00
|
|
|
match Pin::new(&mut foo).resume(()) {
|
2017-08-11 11:54:28 -05:00
|
|
|
GeneratorState::Yielded(3) => {}
|
2017-08-09 18:38:05 -05:00
|
|
|
s => panic!("bad state: {:?}", s),
|
|
|
|
}
|
2020-01-25 13:03:10 -06:00
|
|
|
match Pin::new(&mut foo).resume(()) {
|
2017-08-09 18:38:05 -05:00
|
|
|
GeneratorState::Complete(()) => {}
|
|
|
|
s => panic!("bad state: {:?}", s),
|
|
|
|
}
|
2017-07-07 18:12:44 -05:00
|
|
|
}
|