3 ms·
Other replies have made excellent points but I'd also like to point out that in the world of Rust the only time you want your code to panic is when something ir
by riskable 3y ago
Other replies have made excellent points but I'd also like to point out that in the world of Rust the only time you want your code to panic is when something irrecoverable (at a very low level) happens. Like if you're messing around with bare metal/embedded stuff and you just set a (hardware) register but for whatever reason that call failed so now you can be guaranteed that the rest of your code just can't work. It's panic time!
If a crate is using panic because it encountered bad input or whatever then the crate isn't doing things in a rusty sort of way. Even if it's a wrapper around an unsafe C library that uses panic everywhere the language has tools to work around that which is not the same thing as having made an inherent, unfixable mistake in the design of the language (by having more than one way to deal with errors).