1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use quote::quote;

pub fn async_body(block: Box<syn::Block>) -> syn::Result<proc_macro2::TokenStream> {
    if cfg!(feature = "rust_1_61") {
        Ok(quote! {
            {
                let __snafu_body = async #block;
                <::snafu::Report<_> as ::core::convert::From<_>>::from(__snafu_body.await)
            }
        })
    } else {
        Ok(quote! {
            {
                let __snafu_body = async #block;
                ::core::result::Result::map_err(__snafu_body.await, ::snafu::Report::from_error)
            }
        })
    }
}