3 ms·
Why do you need a separate thread here? Is Rust's panic tied to the currently executing thread?
by charlieflowers 11y ago
Why do you need a separate thread here? Is Rust's panic tied to the currently executing thread?
- burntsushi 11y agoKinda sorta. My knowledge is limited on the topic, but AFAIK, unwinding for Rust is designed to have at most one try/catch block per thread. That said, there is a `catch_panic` function (http://doc.rust-lang.org/std/thread/fn.catch_panic.html http://doc.rust-lang.org/std/thread/fn.catch_panic.html), but it's unstable. So in stable Rust, the only way to catch a panic is to spawn a new thread, I think.