Function allocation_counter::avoid_counting
source · pub fn avoid_counting<F: FnOnce()>(run_while_not_counting: F)
Expand description
Opt out of counting allocations while running some code.
Useful to avoid certain parts of the code flow that should not be counted.
Arguments
run_while_not_counting
- The code to run while not counting allocations
Examples
allocation_counter::assert_no_allocations(|| {
code_that_should_not_allocate();
allocation_counter::avoid_counting(|| {
external_code_that_should_not_be_tested();
});
code_that_should_not_allocate();
});