News for hackers. Stuff that matters.
Re:Things I Enjoy in Rust: Error Handling by CUViper on Monday April 22, 2019 @04:24PM (#19722579)
One thing you may be missing is that the `Result::Err` in your return type must implement `From` for the `Result::Err` type where you're using the `?` operator. That's already covered if those `Err` types are identical (`From<T> for T`), otherwise you need to implement the conversion.

    impl From<QuestionError> for ReturnError {
        fn from(error: QuestionError) -> ReturnError {
            // TODO
            unimplemented!()
        }
    }
Re:Things I Enjoy in Rust: Error Handling by wyldfire on Monday April 22, 2019 @04:34PM (#19722697)
Oh yeah, that's likely it. Thanks!

It it safe to just put a noop in there? What's From-ness? Is QuestionError defined in std? Where do I read more?

EDIT: oh I see, I didn't read carefully. I just need to provide a conversion. Your example is very clear.

Re:Things I Enjoy in Rust: Error Handling by ds206 on Monday April 22, 2019 @04:42PM (#19722768)
It's how you explicitly cast from one type to another. To use the ? operator with a custom error type, it needs to be converted to the std error type.
Re:Things I Enjoy in Rust: Error Handling by steveklabnik on Monday April 22, 2019 @04:44PM (#19722795)
It needs to be converted to whatever error type the function returns. That can be anything.