derive-attribute 0.1.0

A set of macros to automatically deserialize standard attributes
Documentation

A set of macros to automatically deserialize standard attributes

Getting Started

Make sure a Syn version is selected in features: features = ["syn_2"]

Our attribute type is declared in a procedural macro crate:

#[derive(Attribute)]
#[attr(name = "my_attr")] // We set the attribute name to 'my_attr'
struct MyAttribute {      // Note: The attribute name will be the struct name in snake_case by default
name: String,
// wrapping a type in an option will make it optional
list: Option<NestedList>, // deserializes a meta list named list i.e. list(num = 1)

// booleans are always optional
is_selected: bool,
}
#[derive(List)]
pub struct NestedList {
num: Option<u8>
}

It can then be used to parse the following attribute using the from_attrs method:

#[my_attr(name = "some_name", is_selected)]

For a more extensive guide check out the github.