Change the return type to Result<Option<Gender>, Error>. Handle this with the longest chain of conditionals and match blocks you've ever seen.
The drawback is that you run into the halting problem: if the function is invoked, it's impossible to know ahead of time whether there was actually a Gender to return in the first place.
Sincerely,
A noobie Rust programmer that's still in the 64th match block waiting for this method to terminate
The drawback is that you run into the halting problem: if the function is invoked, it's impossible to know ahead of time whether there was actually a
Gender to return in the first place.
(It’s a horrible horrible pun about suboptimal testosterone levels, borrowing the vocabulary of the theorem. I apologize profusely for making it seem like anything more profound!)
42
u/ato-de-suteru Jan 24 '22
Change the return type to
Result<Option<Gender>, Error>. Handle this with the longest chain of conditionals andmatchblocks you've ever seen.The drawback is that you run into the halting problem: if the function is invoked, it's impossible to know ahead of time whether there was actually a
Genderto return in the first place.Sincerely,
A noobie Rust programmer that's still in the 64th
matchblock waiting for this method to terminate16
u/now_im_lily Jan 24 '22
I love that you dropped the
pubfrom the second one lol. Nice touch.9
u/ususetq Jan 24 '22
While I usually like enums I think it should be
-> impl Gender.That way you can have:
8
u/itemboxes Jan 25 '22
panic!();at the disco7
u/SpecialEmily Jan 25 '22
4
u/pine_ary Jan 25 '22
todo!()
1
u/theangeryemacsshibe Jan 25 '22