use async_safe_defer::async_scope;
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), &'static str> {
async_scope!(scope, {
scope.defer(|| async {
println!("disconnect");
});
scope.defer(|| async {
println!("flush");
});
println!("work");
Ok(())
})
.await
}