Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's using rust's ? operator. This operator evaluates to the value if the Result it's called represents success, and propagates the error if it represents failure. This assumes the calling function also returns a Result with an error that's convertible from the error the called function operated on.

In many cases that's enough to handle an error. It's still not a great comparison, since implicitly letting the exception propagate is the closest correspondence in a language that uses exceptions for expected errors.



> implicitly letting the exception propagate

It’s not really implicit though, is it? You’re explicitly asking the language to unwrap the result or propagate the error up out of the function. And the function return value explicitly encodes this, unlike exceptions which can happen anywhere for any reason at any time.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: