ngn@lemy.lol to Programmer Humor@lemmy.mlEnglish · 6 months agogot himlemy.lolimagemessage-square133fedilinkarrow-up1484arrow-down141
arrow-up1443arrow-down1imagegot himlemy.lolngn@lemy.lol to Programmer Humor@lemmy.mlEnglish · 6 months agomessage-square133fedilink
minus-squareAVincentInSpace@pawb.sociallinkfedilinkEnglisharrow-up1·6 months agowhat if i need to if let on the result of another if let
minus-squareRustyNova@lemmy.worldlinkfedilinkarrow-up1·6 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.
minus-squareAVincentInSpace@pawb.sociallinkfedilinkEnglisharrow-up1·6 months agowhat about if on a boolean followed by an if let
what 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.
what about
if
on a boolean followed by anif let