derive_less
A macro for deriving macros. Use it to generate #[...]
and pub
code in item declarations.
Example
Suppose you needed the following code:
;
;
Instead of typing out #[orange]
, #[apple]
, and pub
, repeatedly for each item declaration, you could simply write:
use derive_less;
derive_less!
You can also mix in derives that only apply to certain items/variants/fields, e.g:
use derive_less;
derive_less!
Limitations
Currently supports:
- Structs (All kinds)
- Enums (All kinds)
While structs and enums can take multiple #[...]
, e.g.:
... { ... }
Fields and variants accept at most one #[...]
due to current restrictions in macro_rules!
. In other words, this does not work at the moment:
... { #[
Future work
Add support for:
- Functions
- Traits
- Trait implementations
- Unions
- Type aliases
- Use declarations
Possibly rewrite derive_less!
using Rust's procedural macro interface or through a build-script that generates declarative macro code.