rust/tests/ui/async-await/async-closures/clone-closure.rs

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

23 lines
410 B
Rust
Raw Normal View History

//@ 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 for_each(f: impl AsyncFnOnce(&str) + Clone) {
f.clone()("world").await;
f.clone()("world2").await;
}
fn main() {
block_on::block_on(async_main());
}
async fn async_main() {
let x = String::from("Hello,");
for_each(async move |s| {
println!("{x} {s}");
}).await;
}