6 releases

Uses new Rust 2021

0.1.5 May 5, 2022
0.1.4 Oct 18, 2021
0.1.3 Apr 7, 2021
0.1.0 Mar 28, 2021

#12 in #attribute

Download history 12598/week @ 2022-10-06 9799/week @ 2022-10-13 10268/week @ 2022-10-20 11884/week @ 2022-10-27 9740/week @ 2022-11-03 10541/week @ 2022-11-10 11193/week @ 2022-11-17 9576/week @ 2022-11-24 10759/week @ 2022-12-01 10382/week @ 2022-12-08 11209/week @ 2022-12-15 8279/week @ 2022-12-22 6285/week @ 2022-12-29 9966/week @ 2023-01-05 10051/week @ 2023-01-12 9151/week @ 2023-01-19

36,853 downloads per month
Used in 81 crates (via structmeta)

MIT/Apache

54KB
1.5K SLoC

StructMeta

Crates.io Docs.rs Actions Status

Parse Rust's attribute arguments by defining a struct.

Documentation

See #[derive(StructMeta)] documentation for details.

Example

use structmeta::StructMeta;
use syn::{parse_quote, Attribute, LitInt, LitStr};

#[derive(StructMeta, Debug)]
struct MyAttr {
    x: LitInt,
    y: LitStr,
}
let attr: Attribute = parse_quote!(#[my_attr(x = 10, y = "abc")]);
let attr: MyAttr = attr.parse_args().unwrap();
println!("x = {}, y = {}", attr.x, attr.y.value());

This code outputs:

x = 10, y = abc

License

This project is dual licensed under Apache-2.0/MIT. See the two LICENSE-* files for details.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~195–590KB
~14K SLoC