3 ms·
> The ?/try! utilizes traits to instead allows you to auto-coerce them to a new error with a relevant message/trace (given the appropriate Into definition), all
by masklinn 8y ago
> The ?/try! utilizes traits to instead allows you to auto-coerce them to a new error with a relevant message/trace (given the appropriate Into definition), allowing it to be a simple one-character addition with most of the expressive power of exceptions.
That is not a very important job, because it's a context-less conversion and thus only suitable for pretty basic conversions.
> the "continue or return" part isn't that significant (that would just be avoiding the any language one-liner: if err return err)
"continue or return" is by far the most important part of ?/try!, it reduces an extensive match into a single character or 6, making error handling both terse and simple for the common case where you just want to bubble up the error.
Even if it did not do any conversion, such conversion is just a map_err away (and commonly necessary either way as the developer wants to add context or needs to convert from trait object or some such).
The automatic conversion is a minor convenience.