Hacker News new | ask | show | jobs
by Lorak_ 522 days 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
2 comments

> 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.
As 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?

Did you read the part about types needing to support UnwindSafe.

I typically don’t control every type that I am interacting with.

there'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