6 ms·
The article is wrong on the claim that Rust panic are harder to catch than C++ exceptions: as long as you don't configure panic=abort you can catch them easily
by devit 2y ago
The article is wrong on the claim that Rust panic are harder to catch than C++ exceptions: as long as you don't configure panic=abort you can catch them easily with catch_panic and they are generally implemented using the same runtime mechanism (i.e. Rust panics usually effectively are C++ exceptions for most purposes).
- 01HNNWZ0MV43FF 2y agoHm, it just feels wrong though. Panics feel bigger than exceptions
- int_19h 2y agoThat's a cultural thing (and a good one, too). The one big difference tho is that in Rust, the end user of the library - i.e. the person compiling the binary of which this library is a part - can decide at that point whether panics unwind like C++ exceptions, or just abort immediately. Conversely, this means that the library should never assume that it can catch panics, even its own internal ones, because it may be compiled with panic=abort. So it's kinda like C++ exceptions, but libraries can only throw, never catch.