rust/tests/ui/coroutine/nested_coroutine.rs

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

22 lines
412 B
Rust
Raw Normal View History

// run-pass
2023-10-19 16:46:28 -05:00
#![feature(coroutines, coroutine_trait)]
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;
fn main() {
2023-10-19 16:46:28 -05:00
let _coroutine = || {
let mut sub_coroutine = || {
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) => {
yield x;
}
_ => panic!(),
};
};
}