@[email protected] to Programmer HumorEnglish • 20 days agoProgramming as a hobby means I can do whatever I want!sh.itjust.worksimagemessage-square22fedilinkarrow-up1239arrow-down18
arrow-up1231arrow-down1imageProgramming as a hobby means I can do whatever I want!sh.itjust.works@[email protected] to Programmer HumorEnglish • 20 days agomessage-square22fedilink
minus-square@[email protected]linkfedilink5•18 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@[email protected]linkfedilink4•18 days agoAlso you can use enums insteas of string literals
minus-square@[email protected]OPlinkfedilink1•17 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@[email protected]linkfedilink1•9 days agoIf the message used enums for actions/procedures like SPAM_MEMES, then using enums would be more performant
minus-square@[email protected]OPlinkfedilink2•17 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 ;)