Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

3
Newbie rustacean here. Would appreciate suggestions how to make my code better
Post Body

I'm coming over from C background. The lesson for today was error handling. I set myself a task of defining three custom errors and handling them together with "naturally arising errors"

https://github.com/fireice-uk/rus_errors/blob/main/src/main.rs

  1. I have defined three error types ErrorNumberIsOne ErrorNumberIsTwo ErrorNumberIsOther - any way to cut the boilerplate code there? I tried to make them somehow "inherit" off a shared base but couldn't get it to work

  2. Any way to get the error handling on line 90 to work?

  3. Any way to reduce boilerplate on 102 - 112?

Author
Account Strength
100%
Account Age
10 years
Verified Email
Yes
Verified Flair
No
Total Karma
16,342
Link Karma
10,908
Comment Karma
2,170
Profile updated: 3 days ago
Posts updated: 7 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
3 years ago