1 unstable release
Uses old Rust 2015
|0.1.0||Apr 29, 2017|
Used in 2 crates
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
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
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
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(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
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
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.
prom-attire-bootstrap defines a simple procedural derive macro
FromAttributesBootstrap that calls into
prom-attire-impl with a hardcoded
prom-attire defines a slightly more complicated procedural derive
FromAttributes) that parses some attributes (using a parser derived
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
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
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.