4 ms·
You don't need threads for that, just std::panic::catch_unwind().
by afdbcreid 2y ago
You don't need threads for that, just std::panic::catch_unwind().
- Raicuparta 2y agocatch_unwind doesn't catch all panics. I imagine that running a thread would actually catch all panics, but I don't know enough about the subject to say that confidently. https://doc.rust-lang.org/std/panic/fn.catch_unwind.html#notes https://doc.rust-lang.org/std/panic/fn.catch_unwind.html#not...
- afdbcreid 2y agoAborting panics won't by caught by threads either. And they are common only in two scenarios: if you set panic="abort", or special UB checks that the standard library does. The former is just a simple configuration change, the latter is not really something you can handle in any way.