qadapt
debug_assert!
for your memory usage
This allocator is a helper for writing high-performance code that is memory-sensitive;
a thread panic will be triggered if a function annotated with #[no_alloc]
,
or code inside an assert_no_alloc!
macro interacts with the allocator in any way.
Wanton allocations and unforeseen drops no more - this library lets you focus on
writing code without worrying if Rust properly managed to inline the variable into the stack.
Now, an allocator blowing up in production is a scary thought; that's why QADAPT
is designed to strip its own code out whenever you're running with a release build.
Just like the debug_assert!
macro
in Rust's standard library, it's safe to use without worrying about a unforeseen
circumstance causing your application to crash.
Usage
Actually making use of QADAPT is straight-forward. To set up the allocator, place the following snippet in either your program binaries (main.rs) or tests:
use QADAPT;
static Q: QADAPT = QADAPT;
After that, there are two ways of telling QADAPT that it should trigger a panic:
- Annotate functions with the
#[no_alloc]
proc macro:
use no_alloc;
// This function is fine, there are no allocations here
// This function will trigger a panic when called
- Evaluate expressions with the
assert_no_alloc!
macro
use assert_no_alloc;