attribute-derive
Basicly clap for attribute macros:
#[derive(Attribute)]
#[attribute(ident = "collection")]
#[attribute(invalid_field = "Error when an unsupported value is set (e.g. meaning=42")]
struct CollectionAttribute {
authority: Option<String>,
#[attribute(missing = "Error when the value is not set")]
name: String,
#[attribute(default)]
#[attribute(expected = "Error when an error occured while parsing")]
views: Vec<Type>,
some_flag
}
Will be able to parse an attribute like this:
#[collection(authority="Some String", name = r#"Another string"#, views = [Option, ()])]
Limitations
There are some limitations in syntax parsing that will be lifted future releases.
- literals in top level (meaning something like
#[attr(42, 3.14, "hi")]
- function like arguments (something like
#[attr(view(a = "test"))]
- other syntaxes, maybe something like
key: value