rust/example/polymorphize_coroutine.rs
Oli Scherer dda4709b1c Error on using yield without also using #[coroutine] on the closure
And suggest adding the `#[coroutine]` to the closure
2024-04-24 08:05:29 +00:00

18 lines
303 B
Rust

#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
use std::ops::Coroutine;
use std::pin::Pin;
fn main() {
run_coroutine::<i32>();
}
fn run_coroutine<T>() {
let mut coroutine = #[coroutine]
|| {
yield;
return;
};
Pin::new(&mut coroutine).resume(());
}