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