8 releases (4 stable)

Uses old Rust 2015

new 1.1.1 Mar 5, 2025
1.1.0 May 18, 2024
1.0.1 Oct 7, 2023
1.0.0 Oct 27, 2022
0.1.0 Apr 30, 2018

#961 in Development tools

Download history 37/week @ 2024-11-25 4/week @ 2024-12-09 16/week @ 2025-02-03 109/week @ 2025-02-10 123/week @ 2025-02-17 329/week @ 2025-02-24 1123/week @ 2025-03-03

1,684 downloads per month
Used in rusty-asm

MIT/Apache

25KB
300 lines

runtime-macros

This crate offers a way to emulate the process of procedural macro expansion at run time. It is intended for use with code coverage tools like cargo-tarpaulin, which can't measure the code coverage of anything that happens at compile time.

The runtime-macros crate works with functionlike!, #[attributelike], and #[derive(...)] procedural macros. There are no plans to support declarative macros.

To use runtime-macros, add a test case to your procedural macro crate that calls one of the emulate_*_macro_expansion functions on a .rs file that calls the macro. Most likely, all the files you'll want to use it on will be in your crate's /tests directory. Once you've completed this step, any code coverage tool that works with your crate's test cases will be able to report on how thoroughly you've tested the macro.

See the /examples directory in the repository for working examples.

Dependencies

~210–640KB
~15K SLoC