Rust Panic Handling
This cluster centers on debates about Rust's panic mechanism, including its intended use for unrecoverable errors, recoverability via panic=unwind or panic=abort, comparisons to exceptions, and best practices like unwrap() versus explicit error handling.
Activity Over Time
Top Contributors
Keywords
Sample Comments
Rust has panic, although intended for “unrecoverable” errors only.
Rust has panics that could appear anywhere.
Oh, so it's like Rust's panic=abort
I really don't see how it would've helped. In go or Rust you'd just get a panic, which is in no way different.
Rust panics can be catched too, but it's true that it's less common than in languages with exceptions
Let’s not go too far, Rust has plenty of panics at runtime.
Oh no, I didn't know this. I'm adding panic = "abort" to all my projects. If I wanted exceptions I wouldn't be using rust.
I’m referring to the fact that ubiquitous functions like unwrap() panic if the programmer has made an error. Guarding against such panics is outside of the scope of Rust-the-language, and has to be handled through external means. There are linters for C as well.
Rust does not have exceptions, not even in the limited capacity that Go sort-of has. It's legal for a Rust implementation to translate panics into aborts, which means that they cannot be relied upon as an error-handling mechanism. Furthermore, the means to halt unwinding in Rust exists only to prevent memory unsafety from occurring when Rust is embedded in another language via the C interface, because unwinding across an FFI boundary is undefined behavior. In fact the exact mechanism used i
> Not familiar with Rust but it seems unwrap is such a thing that would be banned.Panics aren't exceptions, any "panic" in Rust can be thought of as an abort of the process (Rust binaries have the explicit option to implement panics as aborts). Companies like Dropbox do exactly this in their similar Rust-based systems, so it wouldn't surprise me if Cloudflare does the same."Banning exceptions" wouldn't have done anything here, what you're l