macro_rules! assert_no_alloc {
    ($e:expr) => { ... };
}
Expand description

Get the result of an expression, guaranteeing that no memory accesses occur during its evaluation.

Example:

use qadapt::assert_no_alloc;

fn main() {
    assert_no_alloc!(2 + 2);
}

Warning: Unexpected behavior will occur when using the return keyword. Because QADAPT doesn’t have an opportunity to clean up, there may be a panic in code that was not intended to be allocation-free. The compiler will warn you that there is an unreachable statement if this happens.

use qadapt::assert_no_alloc;

fn early_return() -> usize {
    assert_no_alloc!(return 8);
}

fn main() {
    let x = early_return();
     
    // This triggers a panic - `Box::new` forces an allocation,
    // and QADAPT still thinks we're in a protected region because
    // of a return in the `early_return()` function
    let b = Box::new(x);
}