Thelie@sh.itjust.works to Programmer Humor@programming.devEnglish · 5 months agoProgramming as a hobby means I can do whatever I want!sh.itjust.worksimagemessage-square23fedilinkarrow-up1239arrow-down18
arrow-up1231arrow-down1imageProgramming as a hobby means I can do whatever I want!sh.itjust.worksThelie@sh.itjust.works to Programmer Humor@programming.devEnglish · 5 months agomessage-square23fedilink
minus-squareanton@lemmy.blahaj.zonelinkfedilinkarrow-up6·5 months 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-squarejimitsoni18@lemmy.ziplinkfedilinkarrow-up4·5 months agoAlso you can use enums insteas of string literals
minus-squareThelie@sh.itjust.worksOPlinkfedilinkarrow-up1·5 months 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-squarejimitsoni18@lemmy.ziplinkfedilinkarrow-up1·5 months agoIf the message used enums for actions/procedures like SPAM_MEMES, then using enums would be more performant
minus-squareThelie@sh.itjust.worksOPlinkfedilinkarrow-up2·5 months 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 ;)