2018-09-06 12:41:12 +00:00
|
|
|
// run-pass
|
|
|
|
|
2017-08-09 20:56:19 +00:00
|
|
|
// aux-build:xcrate.rs
|
|
|
|
|
2023-10-19 21:46:28 +00:00
|
|
|
#![feature(coroutines, coroutine_trait)]
|
2017-07-07 23:12:44 +00:00
|
|
|
|
2017-08-09 20:56:19 +00:00
|
|
|
extern crate xcrate;
|
|
|
|
|
2023-10-19 16:06:43 +00:00
|
|
|
use std::ops::{Coroutine, CoroutineState};
|
2018-10-04 18:49:38 +00:00
|
|
|
use std::pin::Pin;
|
2017-07-07 23:12:44 +00:00
|
|
|
|
|
|
|
fn main() {
|
2017-08-09 20:56:19 +00:00
|
|
|
let mut foo = xcrate::foo();
|
2017-07-07 23:12:44 +00:00
|
|
|
|
2020-01-25 19:03:10 +00:00
|
|
|
match Pin::new(&mut foo).resume(()) {
|
2023-10-19 16:06:43 +00:00
|
|
|
CoroutineState::Complete(()) => {}
|
2017-08-09 20:56:19 +00:00
|
|
|
s => panic!("bad state: {:?}", s),
|
|
|
|
}
|
2017-08-09 23:38:05 +00:00
|
|
|
|
|
|
|
let mut foo = xcrate::bar(3);
|
|
|
|
|
2020-01-25 19:03:10 +00:00
|
|
|
match Pin::new(&mut foo).resume(()) {
|
2023-10-19 16:06:43 +00:00
|
|
|
CoroutineState::Yielded(3) => {}
|
2017-08-09 23:38:05 +00:00
|
|
|
s => panic!("bad state: {:?}", s),
|
|
|
|
}
|
2020-01-25 19:03:10 +00:00
|
|
|
match Pin::new(&mut foo).resume(()) {
|
2023-10-19 16:06:43 +00:00
|
|
|
CoroutineState::Complete(()) => {}
|
2017-08-09 23:38:05 +00:00
|
|
|
s => panic!("bad state: {:?}", s),
|
|
|
|
}
|
2017-07-07 23:12:44 +00:00
|
|
|
}
|