| Crates.io | prom-attire |
| lib.rs | prom-attire |
| version | 0.1.0 |
| created_at | 2017-04-29 10:27:01.179413+00 |
| updated_at | 2017-04-29 10:27:01.179413+00 |
| description | Procedural Macro for Procedural Macros to parse attributes |
| homepage | |
| repository | https://github.com/Nemo157/prom-attire-rs |
| max_upload_size | |
| id | 12419 |
| size | 49,492 |
Procedural Macro Attributes
For when you need the best dressed procedural macro.
This project uses clippy and denies warnings in CI builds. To ensure your
changes will be accepted please check them with cargo clippy (available via
cargo install clippy on nightly rust) before submitting a pull request (along
with cargo test as usual).
Both the nightly date and clippy version used in CI are pinned in the
.travis.yml as clippy sometimes breaks for a few days after a new nightly is
published, feel free to update to a new known good pair anytime as part of a
pull request.
Why not three crates?
One issue with current procedural macros is that crates defining procedural
macros can't use their own procedural macros. In this case prom-attire wants
to have some attributes controlling how it parses the attributes (at the
moment, only the top level "scope" attribute identifier, i.e. the value
attire in #[attire(scope = shoes)]), obviously prom-attire will need to
parse these attributes out to get the details it needs, but the entire point of
prom-attire is to make parsing attributes pain-free, having a manual parser
in prom-attire itself mean any upgrades to the parsing code generated by
prom-attire would probably have to be duplicated in the parsing code inside
prom-attire itself.
Luckily there is a solution, by using three crates ;-)
The base is prom-attire-impl, this implements the entirety of the procedural
derive, but does not itself define a procedural derive macro. Instead it
exports a single function taking in the AST provided to a procedural derive and
some configuration and returns the derived implementation.
Next prom-attire-bootstrap defines a simple procedural derive macro
FromAttributesBootstrap that calls into prom-attire-impl with a hardcoded
configuration.
Finally prom-attire defines a slightly more complicated procedural derive
macro (FromAttributes) that parses some attributes (using a parser derived
with FromAttributesBootstrap), then calls into prom-attire-impl with a
configuration derived from those parsed attributes. This is the "public"
entrypoint to the crates, technically the others could be used but they're
unlikely to be useful.
So, in the end prom-attire is a crate defining a procedural derive macro, to
help developers write procedural derive macros, that uses a procedural derive
in its implementation (no, that is not inception).
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.