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

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

26 lines
555 B
Rust
Raw Normal View History

2024-02-06 14:51:56 -06:00
//@ aux-build:block-on.rs
//@ edition:2021
//@ build-pass
#![feature(async_closure)]
extern crate block_on;
struct NoCopy;
fn main() {
block_on::block_on(async {
async fn call_once(x: impl async Fn()) { x().await }
2024-02-26 17:06:38 -06:00
// check that `&{async-closure}` implements `async Fn`.
call_once(&async || {}).await;
// check that `&{closure}` implements `async Fn`.
call_once(&|| async {}).await;
// check that `&fndef` implements `async Fn`.
async fn foo() {}
call_once(&foo).await;
2024-02-06 14:51:56 -06:00
});
}