rocket_codegen/attribute/entry/
test.rs

1use super::EntryAttr;
2
3use devise::{Spanned, Result};
4use proc_macro2::TokenStream;
5
6/// `#[rocket::async_test]`: calls the attributed fn inside `rocket::async_test`
7pub struct Test;
8
9impl EntryAttr for Test {
10    const REQUIRES_ASYNC: bool = true;
11
12    fn function(f: &mut syn::ItemFn) -> Result<TokenStream> {
13        let (attrs, vis, block, sig) = (&f.attrs, &f.vis, &f.block, &mut f.sig);
14        sig.asyncness = None;
15        Ok(quote_spanned!(block.span() => #(#attrs)* #[test] #vis #sig {
16            ::rocket::async_test(async move #block)
17        }))
18    }
19}