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

> The only problem is that AFAIK (but I'm still learning it) Rust is missing something equivalent to Haskell's do notation.

Rust has essentially specialized do-notation for error handling called the `try!` macro, or more recently, `?`. (`try!` and `?` are exactly equivalent in today's Rust.) Actually, it does just a bit more than standard do-notation would: it also tries to convert your error value at the call site to the error type expected by the return type of the current function.

The problems posed in the OP are pedagogical ones IMO that I hope can be solved. I think the current resource on error handling in the book is good for folks who really want to dive in and figure out the complete story, but it's bad for folks who just want to write code that works without spending a couple hours doing a deep dive. So I think there's room for more targeted pedagogy here.



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

Search: