231
submitted 3 weeks ago by Thelie to c/[email protected]
you are viewing a single comment's thread
view the rest of the comments
[-] [email protected] 5 points 3 weeks ago

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 _

[-] [email protected] 4 points 3 weeks ago

Also you can use enums insteas of string literals

[-] Thelie 1 points 3 weeks ago

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…

[-] [email protected] 1 points 2 weeks ago

If the message used enums for actions/procedures like SPAM_MEMES, then using enums would be more performant

[-] Thelie 2 points 3 weeks ago

That's a good point, thanks. Maybe I'll go without the if entirely, the (janky) code is still very much in flux ;)

this post was submitted on 11 Jun 2024
231 points (96.8% liked)

Programmer Humor

18292 readers
1558 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS