News for hackers. Stuff that matters.
Re:Bugs that the Rust compiler catches for you by nulld3v on Friday May 06, 2022 @12:52AM (#31281442)
The assertion remains true though. Unwrap should only be used if you are prototyping or you are 100% sure it will never actually panic.

It's just like the IndexOutOfBounds exception in Java. Many functions can theoretically throw it, but most libraries and programs do not catch it because usually if it is thrown it means that something happened that the programmer did not expect and therefore the program should crash.

Re:Bugs that the Rust compiler catches for you by elbear on Friday May 06, 2022 @01:07AM (#31281522)
There's a difference between what you should do and what people actually do. If a lot of them use unwrap in production, then OP's argument is valid.
Re:Bugs that the Rust compiler catches for you by nulld3v on Friday May 06, 2022 @01:22AM (#31281588)
The problem would not be that it is commonly used, the problem would be that it is abused. And I don't see that happening currently.

The assertion that "If a library panics on user data, that's a pretty serious bug" remains true.

If a library is panicking on invalid user data, it is because they are abusing panic, which is a serious bug. Or they just didn't realize that their code could panic, which is also a serious bug.