os-rust/tests/ui/coroutine/nested_coroutine.rs

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

24 lines
473 B
Rust
Raw Normal View History

//@ run-pass
#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
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;
fn main() {
let _coroutine = #[coroutine]
|| {
let mut sub_coroutine = #[coroutine]
|| {
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) => {
yield x;
}
_ => panic!(),
};
};
}