A macro that is to `Result::or_else` what `try!` is to `Result::and_then`

let error = 頑張ってね!(result); : )

1 Like

Actually, that does lead to a good name - “endure!”

Since you’re enduring the failure, and continuing to work through it.

(Persevere is just a pain to spell. I keep wanting to throw in an extraneous ‘r’.)

Is it just me, or are Rust developers trying as hard as they can to re-invent checked exceptions with unwinding without actually calling them ‘exceptions’?

@Cyberax, that is kinda off-topic for this discussion (return_if_ok! does the “opposite” of what exceptions would) but I’ll respond anyway. (return_if_ok! is pretty much done as far as I’m concerned.)

“Rust developers” are not a single entity with a single set of ideas and desires. Various people, more or less involved with the project, come up with various ideas.

As to exceptions: yes, multiple people have said that we should avoid using that term even if it would be appropriate, because of the historical baggage associted with it, from “exceptions are only for truely exceptional circumstances” (whatever that means) to “exception considered harmful”. This baggage may or may not apply to Rust’s error/exception handling: the most popular proposals so far, based around Result<T, E> make everything explicit and use the existing machanism of return values rather than adding a parellel machanism of trowing/raising exception independently of the return value.

There’s also no automatic unwinding around Result<T, E>. (There is unwinding with panic!, but that’s separate.)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.