discreet_macros/lib.rs
1// /// This macro implements the FiniteDifferenceStencil2D trait for a struct. This struct should
2// /// contain only instances of Node2D, the differential equation, boundary conditions, and any
3// /// other strategy markers.
4// #[proc_macro_attribute]
5// pub fn stencil2d() {}
6use proc_macro::TokenStream;
7use quote::quote;
8
9#[proc_macro]
10pub fn variable(item: TokenStream) -> TokenStream {
11 let ident = syn::parse_macro_input!(item as syn::Ident);
12 let name = ident.to_string();
13
14 quote! {
15 struct #ident;
16
17 impl Variable for #ident {
18 fn get_name() -> String {
19 String::from(#name)
20 }
21 }
22 }
23 .into()
24}