makero 0.1.2

A `macro_rules!` macro to aid in the creation of complex `macro_rules!` macros
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented1 out of 1 items with examples
  • Size
  • Source code size: 4.54 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.07 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • tjjfvi/makero
    3 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • tjjfvi

By default, macros are processed top-down; for example, foo!(bar!()) will process the foo macro first, using the literal tokens bar ! ( ), and bar will only be processed if foo outputs those tokens verbatim.

Enter makero. Inside makero blocks, invoked helper macros will be processed bottom-up; the below main macro outputs true, but removing makero would cause it to output false instead, as the is_x macro would see make_x ! ( ) instead of x.

use makero::makero;
makero! {
  macro_rules! main {
    () => { is_x!(make_x!()) };
  }

  macro_rules! is_x {
    (x) => { true };
    ($($x:tt)*) => { false };
  }

  macro_rules! make_x {
    () => { x };
  }
}
let out = main!();
assert_eq!(out, true);

The makero macro accepts one or more macro_rules! items; only the top-most one will be externally visible.

Attributes can be applied to the resulting macro by applying them to the top-most macro_rules! definition.