Skip to main content

isolate

Function isolate 

pub fn isolate<R>(body: impl FnOnce() -> R) -> Result<R, Box<dyn Any + Send>>
Expand description

Run body as a panic boundary: a panic inside it (on this thread) unwinds to here and is returned as Err with its payload, and is_isolated answers true meanwhile so the process’s panic hook lets it unwind.

body must leave nothing half-updated that outlives it, or whoever reads that state afterwards must tolerate it (poisoned locks read as unavailable, a dropped channel as closed).

§Errors

The panic payload when body panicked.