Expand description
Safe API for Rโs R_UnwindProtect
This module provides with_r_unwind_protect for handling R errors with Rust cleanup.
It automatically runs Rust destructors when R errors occur.
Important: R uses longjmp for error handling, which normally bypasses Rust destructors.
Use this API to ensure cleanup happens even when R errors occur.
Staticsยง
- R_
CONTINUATION_ ๐TOKEN - Global continuation token for R_UnwindProtect.
Functionsยง
- get_
continuation_ ๐token - Get or create the global continuation token.
- panic_
payload_ ๐ โto_ r_ error - Convert a Rust panic payload into an R error and continue unwinding on the R side.
- panic_
payload_ to_ string - Extract a message from a panic payload.
- run_
r_ ๐unwind_ protect - Core R_UnwindProtect wrapper. Returns
Ok(result)on success,Err(payload)on Rust panic, or diverges viaR_ContinueUnwindon R longjmp. - with_
r_ unwind_ protect - Execute a closure with R unwind protection.
- with_
r_ unwind_ protect_ error_ in_ r - Like
with_r_unwind_protect, but returns a tagged error SEXP on Rust panics instead of raising an R error viaRf_errorcall. - with_
r_ ๐unwind_ protect_ sourced - Like
with_r_unwind_protect, but reports panics with a custom [PanicSource].