News for hackers. Stuff that matters.
Re:Bugs that the Rust compiler catches for you by singularity2001 on Friday May 06, 2022 @02:10AM (#31281838)
What OP meant is that proponents of Rust are often a bit out of touch with reality: Go to github and find a random Rust repo which doesn't use unwrap excessively. And is thus full of serious bugs, according to your wording.
Re:Bugs that the Rust compiler catches for you by nindalf on Friday May 06, 2022 @03:23AM (#31282334)
> Go to github and find one Rust repo which doesn't use unwrap excessively.

Consider serde-json, a widely used library to serialise and deserialise json. You asked me to find “one Rust repo”. Ok here it is - https://github.com/serde-rs/json/search?q=unwrap&type=. Of the 22 uses of unwrap, nearly all are in test code or in comments. Of the remaining 3 or 4, they seem safe to me. But maybe they’re not. Could you think of some json input that could trigger a panic from one of those unwraps?

I’ll put my money where my mouth is. I’ll donate $100 to a charity of your choice if you can find that.

But if you can’t, at least have the honesty to admit that you misspoke when you said not even a single repo without “excessive” use of unwraps exists.

Re:Bugs that the Rust compiler catches for you by pkolaczk on Friday May 06, 2022 @02:58AM (#31282136)
Not every use of unwrap is a bug. For example a regex library returns Result on regex construction because the passed regex could be invalid. But if you construct the regex yourself, from a hard coded string, you know it is correct. Then you just use unwrap and it is ok.
Re:Bugs that the Rust compiler catches for you by pjlegato on Friday May 06, 2022 @12:20PM (#31286963)
People don't write bugs on purpose. That hardcoded string that you know is correct is sometimes not actually correct.
Re:Bugs that the Rust compiler catches for you by Georgelemental on Friday May 06, 2022 @12:53PM (#31287343)
And crashing early is often the best solution in that case.