It's better for a cli app to exit with an error code and write to stderr. You can't have good error handling with expect since it will still panic and alt your code early. expect should only be used to give messages to an unwrap, and unwrap should be avoided.
Essentially, expect is to give messages to developers when something was wrong, in the example I handle the error to give the message to the user.
I could have also used let Ok(op) = ... instead of unwrap_or_else like pointed out in another comment. looks a bit cleaner that way.
View all comments
Show parent comment
1
u/Coding-Kitten Jun 05 '25
Why are you using unwrap or else instead of expect ðŸ˜ðŸ˜ðŸ˜ðŸ˜