Hacker News new | ask | show | jobs
by dnpp123 2373 days ago
AFAIK if you properly define the From/To operator, rust generates it for you.

And if you think about it, defining those operator is a good practice as it tells your program how to handle errors.

1 comments

Or you can use a boxed error iirc. Matching on the type of error after you do that isn't exactly great but it's doable if all you want to do is bubble the error up.

Places where that approach really sucks include web api routes (unless I haven't figured out a trick yet). For example, rocket defines Responder on Result so long as the ok and error variants both define it, but since a boxed error is erased it doesn't function correctly.