2018-09-06 14:41:12 +02:00
|
|
|
//@ run-pass
|
|
|
|
|
2024-04-11 13:15:34 +00:00
|
|
|
#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
|
2017-10-07 16:36:28 +02:00
|
|
|
|
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-10-07 16:36:28 +02:00
|
|
|
|
|
|
|
fn main() {
|
2024-04-11 13:15:34 +00:00
|
|
|
let _coroutine = #[coroutine]
|
|
|
|
|| {
|
|
|
|
let mut sub_coroutine = #[coroutine]
|
|
|
|
|| {
|
2017-10-07 16:36:28 +02:00
|
|
|
yield 2;
|
|
|
|
};
|
|
|
|
|
2023-10-19 21:46:28 +00:00
|
|
|
match Pin::new(&mut sub_coroutine).resume(()) {
|
2023-10-19 16:06:43 +00:00
|
|
|
CoroutineState::Yielded(x) => {
|
2017-10-07 16:36:28 +02:00
|
|
|
yield x;
|
|
|
|
}
|
|
|
|
_ => panic!(),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|