4 ms·
> "try!" has a built-in, hidden function return. Hence the reason I said that it abstracts control flow. > It's only useful if the appropriate error action is
by burntsushi 10y ago
> "try!" has a built-in, hidden function return.
Hence the reason I said that it abstracts control flow.
> It's only useful if the appropriate error action is to immediately bail out of the function.
Which is exceptionally common.
> It implies that your program should be structured as functions which either succeed or fail, and that you don't need to log or display errors where they occur.
None of this is true, and I do log errors when they occur in Rust programs. (See ripgrep.)
`try!` is a convenience. Since errors are plain old values like anything else, you don't actually need to use it if it doesn't fit.