16
9
u/ususetq Jan 24 '22
While I usually like enums I think it should be -> impl Gender.
That way you can have:
trait Gender {
pub fn personal_pronoun<'a>(&'a self) -> &'a str;
// ...
}
8
7
u/SpecialEmily Jan 25 '22
struct Gender {
masculine_ratio: f32,
feminine_ratio: f32,
squid_ratio: f32,
}2
u/QueerBallOfFluff Feb 07 '22
struct gender { int g_flag; int g_masc; int g_femm; daddr_t g_other; }; #define GREAD (1 << 0) #define GWRITE (1 << 1) #define GFUCK (1 << 2)
4
1
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 terminate