4 ms·
I agree that libraries should avoid panicking, but it is not true you can't do anything about it. You can wrap a call to such library into https://doc.rust-lang
by Lorak_ 2y ago
I agree that libraries should avoid panicking, but it is not true you can't do anything about it. You can wrap a call to such library into https://doc.rust-lang.org/std/panic/fn.catch_unwind.html https://doc.rust-lang.org/std/panic/fn.catch_unwind.html
- prmph 2y ago> This function might not catch all Rust panics. A Rust panic is not always implemented via unwinding, but can be implemented by aborting the process as well. This function only catches unwinding panics, not those that abort the process.
- Lorak_ 2y agoAs far as I know panics abort instead of unwinding in three cases: - When a panic happens during panic unwinding - When the application (not the dependency!) sets panics to abort in Cargo.toml - When the target doesn't support unwinding. Which of those is the case for the desktop app described by the parent?
- threeseed 2y agoDid you read the part about types needing to support UnwindSafe. I typically don’t control every type that I am interacting with.
- DrMeepster 2y agothere's a wrapper type, AssertUnwindSafe to get around it. The whole concept of unwind safety was a mistake so don't worry about using it