rust/tests/ui/coroutine/async-gen-yield-ty-is-unit.rs
Kevin Reid c48cdfe8ee Remove unnecessary lets and borrowing from Waker::noop() usage.
`Waker::noop()` now returns a `&'static Waker` reference, so it can be
passed directly to `Context` creation with no temporary lifetime issue.
2024-01-17 12:00:27 -08:00

17 lines
403 B
Rust

// compile-flags: --edition 2024 -Zunstable-options
// check-pass
#![feature(async_iterator, gen_blocks, noop_waker)]
use std::{async_iter::AsyncIterator, pin::pin, task::{Context, Waker}};
async gen fn gen_fn() -> &'static str {
yield "hello"
}
pub fn main() {
let async_iterator = pin!(gen_fn());
let ctx = &mut Context::from_waker(Waker::noop());
async_iterator.poll_next(ctx);
}