pub fn with_r_unwind_protect_or_raise<F, R>(f: F, call: Option<SEXP>) -> Rwhere
F: FnOnce() -> R,Expand description
Execute a closure with R unwind protection, raising any Rust panic as an R
error via Rf_eval(stop(structure(...))).
If the closure panics, the panic is caught and converted to an R error
(longjmp) with rust_* class layering. If R raises an error (longjmp), all
Rust RAII resources are properly dropped before R continues unwinding.
This is NOT the user-facing path for #[miniextendr] functions. That
path is with_r_unwind_protect, which returns a tagged SEXP instead of
longjmping (the macro-generated R wrapper raises the structured condition).
This raising-variant exists for guard sites that have no R wrapper between them and R’s runtime:
- ALTREP
RUnwindguard callbacks (viawith_r_unwind_protect_sourced) - FFI guard tests / benchmarks exercising the raw
R_UnwindProtectmechanism
In those contexts there is no consumer-side R wrapper to inspect a tagged
SEXP. Panics are routed through raise_rust_condition_via_stop so they
still receive rust_* class layering (issue #345). Trait-ABI shims use a
separate SEXP-returning variant (with_r_unwind_protect_shim) that
re-panics at the View boundary.
§Arguments
f- The closure to executecall- Optional R call SEXP for better error messages