pub fn with_r_unwind_protect<F, R>(f: F, call: Option<SEXP>) -> Rwhere
F: FnOnce() -> R,Expand description
Execute a closure with R unwind protection.
If the closure panics, the panic is caught and converted to an R error. If R raises an error (longjmp), all Rust RAII resources are properly dropped before R continues unwinding.
§Arguments
f- The closure to executecall- Optional R call SEXP for better error messages
§Example
ⓘ
let result: i32 = with_r_unwind_protect(|| {
// Code that might call R APIs that can error
42
}, None);