4 ms·
I think the idea is that `expect()` accomplishes the same thing, but allows you to put an explanation of why the function should be total (such that if it does
by Diggsey 4y ago
I think the idea is that `expect()` accomplishes the same thing, but allows you to put an explanation of why the function should be total (such that if it does indeed panic, you can see what went wrong with the reasoning).
That said, I do think there's a place for "unwrap" in eg. tests.
- dietrichepp 4y agoThat seems even more verbose, for a simple function that is already very verbose to begin with, given how little the function does.
- ericbarrett 4y agoI find 9 times out of 10, the source location of the panic (main.rs:123) is enough for debugging, and the .expect() text is redundant. I would never advocate .unwrap() for production services where other people may have to debug the code years after you write it, but there are many, many other use cases for Rust.