mattro-rs
mattro
is a proc_macro attribute parser for Rust.
Usage
Add this to your Cargo.toml:
[dependencies]
mattro = "0.1.1"
You can parse:
Attribute
usingMacroAttribute::new(attribute)
AttributeArgs
usingMacroAttribute::from_attribute_args(path, args, style)
Example
Parsing AttributeArgs
:
main.rs
lib.rs
use MacroAttribute;
use TokenStream;
This prints out:
NameValue(
NameValue ,
)
NameValue(
NameValue ,
)
NameValue(
NameValue ,
)
You could convert the attribute into a name-value
pairs
// Converts the attribute into a `name-value` attribute
let name_values_attributes = attr.into_name_values.unwrap;
// Iterate over the `name-value` pairs
for in &name_values_attributes
This prints out:
"some text"
120