[−][src]Function qadapt::enter_protected
pub fn enter_protected()
Deprecated since 1.0.3:
Please use the alloc_counter
crate instead.
Let QADAPT know that we are now entering a protected region and that panics should be triggered if allocations/drops happen while we are running.
Example:
use qadapt::enter_protected; use qadapt::exit_protected; use qadapt::QADAPT; #[global_allocator] static Q: QADAPT = QADAPT; fn main() { // Force an allocation by using a Box let x = Box::new(2); enter_protected(); // We're now in a memory-protected region - allocations and drops // here will trigger thread panic let y = *x * 4; exit_protected(); // It's now safe to allocate/drop again let z = Box::new(y); }