Use darling in style_derive

This allows use to handle #[css] in a way simpler fashion.
This commit is contained in:
Anthony Ramine 2017-08-24 00:48:59 +02:00
parent 49a5ceca9b
commit 17d97cf87b
5 changed files with 63 additions and 42 deletions

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use darling::FromVariant;
use quote::Tokens;
use std::borrow::Cow;
use std::iter;
@ -136,6 +137,16 @@ where
}
}
pub fn parse_variant_attrs<A>(variant: &Variant) -> A
where
A: FromVariant,
{
match A::from_variant(variant) {
Ok(attrs) => attrs,
Err(e) => panic!("failed to parse attributes: {}", e),
}
}
pub fn ref_pattern<'a>(
name: &Ident,
variant: &'a Variant,