Comment Comment by biokoda > There's no middle ground.Not at all. This is what the ? operator is for (was try! before).The idiomatic rust way is to have your own Error type that implements From for other Error types that you may encounter (io::Error, Utf8Error, etc.).Then you can simply just write let result = dosomething()?; for any operation that may fail. If an error happens, function will return with the error.I don't think you can do it any cleaner, given the constraints Rust is operating under. parent biokoda 9 years ago
Not at all. This is what the ? operator is for (was try! before).
The idiomatic rust way is to have your own Error type that implements From for other Error types that you may encounter (io::Error, Utf8Error, etc.).
Then you can simply just write let result = dosomething()?; for any operation that may fail. If an error happens, function will return with the error.
I don't think you can do it any cleaner, given the constraints Rust is operating under.