moxy-derive 0.0.4

derive macros for moxy crate
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::core::Attrs;

pub struct VariantSyntax {
    pub alias: Option<String>,
    pub skip: bool,
}

impl VariantSyntax {
    pub fn parse(attrs: &Attrs) -> syn::Result<Self> {
        let variant_args = attrs.get("variant")?;
        let attr = variant_args.iter().find_map(|a| a.as_attr());

        let skip = attr.map(|a| a.exists("skip")).unwrap_or(false);
        let alias = attr.and_then(|a| a.get_string("alias"));

        Ok(Self { alias, skip })
    }
}