rust/tests/ui/async-await/async-closures/overlapping-projs.rs

26 lines
395 B
Rust
Raw Permalink Normal View History

2024-04-05 20:48:12 +00:00
//@ aux-build:block-on.rs
//@ edition:2021
//@ run-pass
//@ check-run-results
extern crate block_on;
2024-11-04 18:59:57 +00:00
async fn call_once(f: impl AsyncFnOnce()) {
2024-04-05 20:48:12 +00:00
f().await;
}
async fn async_main() {
let x = &mut 0;
let y = &mut 0;
let c = async || {
*x = 1;
*y = 2;
};
call_once(c).await;
println!("{x} {y}");
}
fn main() {
block_on::block_on(async_main());
}