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.
[ Parent
| on HN ]
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.