30 lines
611 B
Rust
Raw Normal View History

// 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
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);
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),
}
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
}