2018-09-06 07:41:12 -05:00
|
|
|
// run-pass
|
|
|
|
|
2023-10-19 16:46:28 -05:00
|
|
|
#![feature(coroutines, coroutine_trait)]
|
2017-10-07 09:36:28 -05:00
|
|
|
|
2023-10-19 11:06:43 -05:00
|
|
|
use std::ops::{Coroutine, CoroutineState};
|
2018-10-04 13:49:38 -05:00
|
|
|
use std::pin::Pin;
|
2017-10-07 09:36:28 -05:00
|
|
|
|
|
|
|
fn main() {
|
2023-10-19 16:46:28 -05:00
|
|
|
let _coroutine = || {
|
|
|
|
let mut sub_coroutine = || {
|
2017-10-07 09:36:28 -05:00
|
|
|
yield 2;
|
|
|
|
};
|
|
|
|
|
2023-10-19 16:46:28 -05:00
|
|
|
match Pin::new(&mut sub_coroutine).resume(()) {
|
2023-10-19 11:06:43 -05:00
|
|
|
CoroutineState::Yielded(x) => {
|
2017-10-07 09:36:28 -05:00
|
|
|
yield x;
|
|
|
|
}
|
|
|
|
_ => panic!(),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|