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};
|
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
|
|
|
|
2018-03-20 00:48:41 +01:00
|
|
|
match unsafe { 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);
|
|
|
|
|
2018-03-20 00:48:41 +01:00
|
|
|
match unsafe { 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),
|
|
|
|
}
|
2018-03-20 00:48:41 +01:00
|
|
|
match unsafe { 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
|
|
|
}
|