Skip to main content

catch_user_panic_result

Function catch_user_panic_result 

Source
pub fn catch_user_panic_result<R, F>(site: &str, f: F) -> Option<R>
where F: FnOnce() -> R,
Expand description

Run a result-returning callback and convert any contained panic to None.

Returns Some(result) when f completes normally. On panic, reports a best-effort diagnostic, contains panic-payload destruction, and returns None so the caller can provide the ABI-appropriate fallback value.

Like catch_user_panic, this cannot contain a capture destructor that panics while f is already unwinding. Use catch_user_panic_result_with_cleanup for potentially panicking teardown state.

This helper contains one panic from panic-payload destruction, but cannot contain multiple panicking fields within one opaque aggregate.