1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
extern crate proc_macro; use proc_macro::TokenStream;
use syn::{parse_macro_input, DeriveInput};
use syn;
mod macros;
use crate::macros::crud_table_impl::{impl_crud_driver};
#[proc_macro_derive(PGCRUD)]
pub fn derive_builder(input: TokenStream) -> TokenStream {
let derive_input = parse_macro_input!(input as DeriveInput);
let result = match derive_input.data {
syn::Data::Struct(ref data_struct) => impl_crud_driver(&derive_input, &data_struct.fields),
_ => panic!("doesn't work with unions yet"),
};
result.into()
}