blob: 1abc5dab85cf3a84a173dec68446d52e8b05c805 [file] [log] [blame]
David Tolnayf3a9afa2020-10-08 23:22:12 -07001use crate::syntax::Derive;
2use proc_macro2::TokenStream;
3use quote::{quote, ToTokens};
4
5pub struct DeriveAttribute<'a>(pub &'a [Derive]);
6
7impl<'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}