rust/tests/ui/async-await/async-closures/once.rs

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

24 lines
573 B
Rust
Raw Permalink Normal View History

2024-02-06 20:51:56 +00:00
//@ aux-build:block-on.rs
//@ edition:2021
//@ build-pass
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
2024-02-06 20:51:56 +00:00
use std::future::Future;
extern crate block_on;
// Check that async closures always implement `FnOnce`
2024-02-06 20:51:56 +00:00
fn main() {
block_on::block_on(async {
async fn call_once<F: Future>(x: impl FnOnce(&'static str) -> F) -> F::Output {
2024-02-06 20:51:56 +00:00
x("hello, world").await
}
call_once(async |x: &'static str| {
println!("hello, {x}");
}).await
});
}