pub unsafe fn catch_unwind_and_longjmp<R>(f: impl FnOnce() -> R) -> R
Expand description
Invokes the closure f
and returns the result.
If f
panics and this crate is compiled with panic=unwind
this will
catch the panic and capture it to “throw” with longjmp
to be caught by
the nearest setjmp
. The panic will then be resumed from where it is
caught.
§Safety
Only safe to call when wasm code is on the stack, aka catch_traps
must
have been previously called. Additionally no Rust destructors can be on the
stack. They will be skipped and not executed in the case that f
panics.