Function construct_box_uncaught

Source
pub fn construct_box_uncaught<T: MemConstruct, F: FnOnce(T::Constructor) -> T::ConstructorFinishedToken>(
    construct: F,
) -> Box<T>
Expand description

Safely construct a box that holds a value of T that is constructed directly on the heap, skipping the construction on the stack.

This constructtions catches panics inside the passes construct function and deallocates the previously allocated memory, it resumes the unwind after deallocating. If the passed closure are not UnwindSafe or the type T is not [RefUnwindSafe] consider using the construct_box_uncaught function which will leak the memory on panic.

ยงPanics:

This function panics if allocation of values of type T fail.