Derive the most trivial ToCss implementations 🌋

For now, all variants get serialised as the space-separated serialisations
of their fields. Unit variants are not supported.
This commit is contained in:
Anthony Ramine 2017-06-04 15:45:09 +02:00
parent 6d6f03974d
commit c4f1d647a0
18 changed files with 113 additions and 263 deletions

View file

@ -11,6 +11,7 @@ use proc_macro::TokenStream;
mod has_viewport_percentage;
mod to_computed_value;
mod to_css;
#[proc_macro_derive(HasViewportPercentage)]
pub fn derive_has_viewport_percentage(stream: TokenStream) -> TokenStream {
@ -23,3 +24,9 @@ pub fn derive_to_computed_value(stream: TokenStream) -> TokenStream {
let input = syn::parse_derive_input(&stream.to_string()).unwrap();
to_computed_value::derive(input).to_string().parse().unwrap()
}
#[proc_macro_derive(ToCss)]
pub fn derive_to_css(stream: TokenStream) -> TokenStream {
let input = syn::parse_derive_input(&stream.to_string()).unwrap();
to_css::derive(input).to_string().parse().unwrap()
}