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 33
// Sample usage // // #[impl_table(with_columns(id, timestamps))] // #[derive(Table)] // // Optionally generate an id column and two timestamp columns: created_at and // // updated_at. // struct Book { // #[column] name: String, // #[column] pub published_at: DateTime<Utc>, // #[column(rename = 'author_id')] author: i64, // } // // #[derive(Table)] // struct Person { // // If id is not generated, specify the primary key. // #[primary_key] name: String, // #[column] date_of_birth: DateTime<Utc>, // } // extern crate proc_macro; extern crate proc_macro2; use proc_macro::TokenStream; #[proc_macro_derive(Table, attributes(column, primary_key))] pub fn derive_table(_item: TokenStream) -> TokenStream { TokenStream::new() } #[proc_macro_attribute] pub fn impl_table(_attr: TokenStream, item: TokenStream) -> TokenStream { item }