| ▲ | nine_k 2 hours ago | |
But a panic can be caught and handled safely (e.g. via std:: panic tools). I'd say that this is the correct use case for exceptions (ask Martin Fowler, of all people). There is already a try/catch around that code, which produces the Result type, which you can presumptuously .unwrap() without checking if it contains an error. Instead, one should use the question mark operator, that immediately returns the error from the current function if a Result is an error. This is exactly similar to rethrowing an exception, but only requires typing one character, the "?". | ||