Function catch_alloc_error

Source
pub fn catch_alloc_error<F: FnOnce() -> R + UnwindSafe, R>(
    f: F,
) -> Result<R, AllocError>
Expand description

Invokes a closure, capturing the panic of memory allocation error if one occurs.

This function will return Ok with the closure’s result if the closure does not panic, and will return AllocError if allocation error occurs. The process will abort if other panics occur.

Notes that this function will set panic hook and alloc error hook.