blob: 8502bb6e2d45da103fa0a50760f89f7b9b744029 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
//@ edition:2021
#![feature(async_closure)]
fn main() {
fn needs_async_fn(_: impl async Fn()) {}
let mut x = 1;
needs_async_fn(async || {
//~^ ERROR expected a closure that implements the `async Fn` trait, but this closure only implements `async FnMut`
x += 1;
});
let x = String::new();
needs_async_fn(move || async move {
//~^ ERROR expected a closure that implements the `async Fn` trait, but this closure only implements `async FnOnce`
println!("{x}");
});
}
|