@Thelie@sh.itjust.works to Programmer Humor@programming.devEnglish • 17 days agoProgramming as a hobby means I can do whatever I want!sh.itjust.worksimagemessage-square15fedilinkarrow-up1235
arrow-up1235imageProgramming as a hobby means I can do whatever I want!sh.itjust.works@Thelie@sh.itjust.works to Programmer Humor@programming.devEnglish • 17 days agomessage-square15fedilink
minus-square@antonlink5•15 days agoInstead of if let Some(a_) = a{ () } else if let Some(b_)=b{ () } else { dostuff } you could just use if a.isNone()&&b.isNone(){ dostuff } Also if you don’t use the value in a match just use _
minus-square@jimitsoni18@lemmy.ziplinkfedilink4•15 days agoAlso you can use enums insteas of string literals
minus-square@Thelie@sh.itjust.worksOPlinkfedilink1•14 days agoI’m not sure how I would go about this in an elegant way since I’m matching the string I get from a message…
minus-square@jimitsoni18@lemmy.ziplinkfedilink1•6 days agoIf the message used enums for actions/procedures like SPAM_MEMES, then using enums would be more performant
minus-square@Thelie@sh.itjust.worksOPlinkfedilink2•14 days agoThat’s a good point, thanks. Maybe I’ll go without the if entirely, the (janky) code is still very much in flux ;)
Instead of
if let Some(a_) = a{ () } else if let Some(b_)=b{ () } else { dostuff }
you could just use
if a.isNone()&&b.isNone(){ dostuff }
Also if you don’t use the value in a match just use
_
Also you can use enums insteas of string literals
I’m not sure how I would go about this in an elegant way since I’m matching the string I get from a message…
If the message used enums for actions/procedures like SPAM_MEMES, then using enums would be more performant
That’s a good point, thanks. Maybe I’ll go without the if entirely, the (janky) code is still very much in flux ;)