| 1 | //! Derive a builder for a struct |
| 2 | |
| 3 | #![crate_type = "proc-macro" ] |
| 4 | #![deny (warnings)] |
| 5 | |
| 6 | extern crate proc_macro; |
| 7 | #[macro_use ] |
| 8 | extern crate syn; |
| 9 | extern crate derive_builder_core; |
| 10 | |
| 11 | use proc_macro::TokenStream; |
| 12 | |
| 13 | /// Create a builder struct for the deriving struct. |
| 14 | /// |
| 15 | /// See the `derive_builder` crate documentation for more details. |
| 16 | #[proc_macro_derive ( |
| 17 | Builder, |
| 18 | attributes( |
| 19 | builder, |
| 20 | builder_field_attr, |
| 21 | builder_impl_attr, |
| 22 | builder_setter_attr, |
| 23 | builder_struct_attr |
| 24 | ) |
| 25 | )] |
| 26 | pub fn derive(input: TokenStream) -> TokenStream { |
| 27 | let ast: DeriveInput = parse_macro_input!(input as syn::DeriveInput); |
| 28 | derive_builder_core::builder_for_struct(ast).into() |
| 29 | } |
| 30 | |