rust/tests/ui/coroutine/xcrate.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
648 B
Rust
Raw Normal View History

// run-pass
2017-08-09 13:56:19 -07:00
// aux-build:xcrate.rs
2023-10-19 21:46:28 +00:00
#![feature(coroutines, coroutine_trait)]
2017-07-07 16:12:44 -07:00
2017-08-09 13:56:19 -07:00
extern crate xcrate;
2023-10-19 16:06:43 +00:00
use std::ops::{Coroutine, CoroutineState};
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
match Pin::new(&mut foo).resume(()) {
2023-10-19 16:06:43 +00:00
CoroutineState::Complete(()) => {}
2017-08-09 13:56:19 -07:00
s => panic!("bad state: {:?}", s),
}
2017-08-09 16:38:05 -07:00
let mut foo = xcrate::bar(3);
match Pin::new(&mut foo).resume(()) {
2023-10-19 16:06:43 +00:00
CoroutineState::Yielded(3) => {}
2017-08-09 16:38:05 -07:00
s => panic!("bad state: {:?}", s),
}
match Pin::new(&mut foo).resume(()) {
2023-10-19 16:06:43 +00:00
CoroutineState::Complete(()) => {}
2017-08-09 16:38:05 -07:00
s => panic!("bad state: {:?}", s),
}
2017-07-07 16:12:44 -07:00
}