rust/tests/ui/async-await/async-closures/box-deref-in-debuginfo.rs

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

36 lines
586 B
Rust
Raw Normal View History

//@ aux-build:block-on.rs
//@ edition:2021
//@ run-pass
#![feature(async_closure)]
extern crate block_on;
pub trait Trait {
fn callback(&mut self);
}
impl Trait for (i32,) {
fn callback(&mut self) {
println!("hi {}", self.0);
self.0 += 1;
}
}
async fn call_once(f: impl async FnOnce()) {
f().await;
}
async fn run(mut loader: Box<dyn Trait>) {
let f = async move || {
loader.callback();
loader.callback();
};
call_once(f).await;
}
fn main() {
block_on::block_on(async {
run(Box::new((42,))).await;
});
}