3 ms·
It is a shame there are so many Rust examples out there with unwrap() all over them, because it's really not something I would want to see in production code. e
by mathw 5y ago
It is a shame there are so many Rust examples out there with unwrap() all over them, because it's really not something I would want to see in production code. expect() with a message if you know that the only reason this fails is because something else messed up that should have prevented the call in the first place, sure. unwrap()? No thanks. That's why we have the ? operator now.
- da39a3ee 5y agoAgreed, except I don't think people should use expect() since its name is a mistake made early on in Rust: people use it to write expect("something bad we don't expect") unwrap_or_else(|| panic!(...)) is clear and doesn't suffer from the naming mistake.