| David Tolnay | f3a9afa | 2020-10-08 23:22:12 -0700 | [diff] [blame^] | 1 | use crate::syntax::Derive; |
| 2 | use proc_macro2::TokenStream; | ||||
| 3 | use quote::{quote, ToTokens}; | ||||
| 4 | |||||
| 5 | pub struct DeriveAttribute<'a>(pub &'a [Derive]); | ||||
| 6 | |||||
| 7 | impl<'a> ToTokens for DeriveAttribute<'a> { | ||||
| 8 | fn to_tokens(&self, tokens: &mut TokenStream) { | ||||
| 9 | if !self.0.is_empty() { | ||||
| 10 | let derives = self.0; | ||||
| 11 | tokens.extend(quote!(#[derive(#(#derives),*)])); | ||||
| 12 | } | ||||
| 13 | } | ||||
| 14 | } | ||||