Comments by "p11" (@porky1118) on "Why I Prefer Exceptions To Errors" video.
-
1
-
3:50 Yeah, if you have to use unwrap, you probably did something wrong.
In most cases, you can get the values using if-let.
If you expect something to fail, avoid using unwrap, but either forward the error to the next function or generate some error message for the user, if possible one which doesn't kill the program.
If you know, it won't fail, then unwrap is acceptable, but I'd still use except, just to be sure, or use unwrap_unsafe, if you're really sure.
1