shared_tokio_runtime_macros/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#[allow(unused_extern_crates)]
extern crate proc_macro;

use quote::ToTokens;
use syn::{parse_quote, ItemFn};

#[proc_macro]
pub fn runtime(input_stream: proc_macro::TokenStream) -> proc_macro::TokenStream {
    input_stream
    // let input_stream: proc_macro2::TokenStream = input_stream.into();
    // let mut input: ItemFn = match syn::parse2(input_stream.clone()) {
    //     Ok(it) => it,
    //     Err(_) => panic!("The `runtime` macro attribute is only valid when called on a fn."),
    // };
    // input.sig.asyncness = None;
    // let block = input.block;
    // input.block = parse_quote! {
    //     shared_tokio_runtime::rt().block_on(async {
    //         #block
    //     })
    // };
    // input.into_token_stream().into()
}