4 releases

0.2.1 May 25, 2020
0.2.0 Aug 24, 2019
0.1.1 Feb 7, 2019
0.1.0 Feb 6, 2019

#177 in Parser tooling

Download history 11410/week @ 2023-12-15 4194/week @ 2023-12-22 5967/week @ 2023-12-29 10243/week @ 2024-01-05 7965/week @ 2024-01-12 9233/week @ 2024-01-19 9577/week @ 2024-01-26 10633/week @ 2024-02-02 13203/week @ 2024-02-09 12062/week @ 2024-02-16 12022/week @ 2024-02-23 11367/week @ 2024-03-01 14630/week @ 2024-03-08 14672/week @ 2024-03-15 12075/week @ 2024-03-22 8917/week @ 2024-03-29

52,299 downloads per month
Used in 8 crates (2 directly)

Apache-2.0 OR MIT

12KB
130 lines

Synattra

Build Status License Cargo Documentation Rust 1.31+

A Syn Attribute Parser Toolkit

Synattra extends Syn and provides structures to easily parse custom attributes.

Notably, Synattra provides a KVOption<K, V> type that allows parsing attributes in the form key = value where key can be any token or custom keyword (including Rust keywords!) and value any type that can be parsed from a TokenStream. Synattra was extracted from the Metered project which needed expressing type paths as option values (e.g path::to::GenericType<u32>), which was not supported by existing attribute parsing systems (neither Syn's own Meta parsing facility or alternate crates such as prom-attire-rs).

Synattra also supports single or multiple values, that can take the shape of Foo or [Foo, Bar].

Finally Synattra provides some extra types, such as InvokePath which represents any invocation handle, macro or not (e.g foo or println!).

By reusing Syn's design, Synattra parsers are very robust and when they compile, they usually work :-).

Changelog

  • 0.2.0:
    • Updated dependencies to use syn, proc-macro2 and quote 1.0

Required Rust version

Synattra runs on Rust stable.

Design

Synattra is using Syn's design for attribute parsing. You can see it in use in the Metered project.

License

Licensed under either of

at your option.

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

~1–1.4MB
~33K SLoC