allocation-counter
Run some Rust code while counting allocations.
Example usage:
Add as a dependency:
[]
= ["allocation-counter"]
[]
= { = "0", = true }
Since including the trait replaces the global memory allocator, you most likely want it gated behind a feature.
You can now assert that the function does not allocate memory by running tests with the necessary feature enabled: