ngn@lemy.lol to Programmer Humor@lemmy.mlEnglish · 7 months agogot himlemy.lolimagemessage-square129fedilinkarrow-up1222arrow-down122
arrow-up1200arrow-down1imagegot himlemy.lolngn@lemy.lol to Programmer Humor@lemmy.mlEnglish · 7 months agomessage-square129fedilink
minus-squareRustyNova@lemmy.worldlinkfedilinkarrow-up0·7 months agoUse a match? Unless it’s for guard clauses, a match is fine enough
minus-squareAVincentInSpace@pawb.sociallinkfedilinkEnglisharrow-up0·7 months agowhat if i need to if let on the result of another if let
minus-squareRustyNova@lemmy.worldlinkfedilinkarrow-up0·7 months agoOh, then you use and_then() or something similar. There’s also the possibility to use the guard clauses patern and do let <...> = <...> else {}. And finally, you can always split into another function. It’s not straight rules. It depends on what makes it more readable for your case.
Use a
match
? Unless it’s for guard clauses, a match is fine enoughwhat if i need to
if let
on the result of anotherif let
Oh, then you use
and_then()
or something similar.There’s also the possibility to use the guard clauses patern and do
let <...> = <...> else {}
.And finally, you can always split into another function.
It’s not straight rules. It depends on what makes it more readable for your case.