Also, sometimes just unwrap it. There is some software where it's perfectly fine to panic. If there is no sane default value and there is nothing you can do to recover from the error, just unwrap. Also, sometimes you just write software where you know the invariant is enforced so a type is never None, you can unwrap there too. I find it interesting how a lot of people find Rust annoying because idiomatic Rust is a ve…
Imo always expect rather than unwrap in those cases. If it's justifiable, you should justify it in the message. ("This should never happen because: ..., if you see this message there's a bug.")
Re: Don't unwrap options: There are better ways (2024)
#61If you’re doing something like Project Euler, writing error messages is a waste of time.