]> git.cworth.org Git - rust-learning/commit
Use expect instead of unwrap_or_else
authorCarl Worth <cworth@cworth.org>
Tue, 10 Mar 2026 14:56:54 +0000 (07:56 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 12 Mar 2026 04:14:58 +0000 (21:14 -0700)
commite5b648c01829bc01c6e3b1381c2499b9ad8e3043
tree9072ae92287cfae63e793deeae82f526596a1541
parent9ba9c3c5672f4b0ebd63d47976371698e1381d72
Use expect instead of unwrap_or_else

I just learned about this convenient method provided by Result.
Compared to using unwrap_or_else, I don't need to explicitly call
std::process::exit() and compared to using ? I still get to control
the error string (to include the filename in it).
src/main.rs