Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


People don't write bugs on purpose. That hardcoded string that you know is correct is sometimes not actually correct.


And crashing early is often the best solution in that case.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: