azdle@news.idlestate.org to Rust@programming.devEnglish · 2 months agothings rust shipped without (2015)graydon2.dreamwidth.orgexternal-linkmessage-square25fedilinkarrow-up133arrow-down12cross-posted to: lobsters
arrow-up131arrow-down1external-linkthings rust shipped without (2015)graydon2.dreamwidth.orgazdle@news.idlestate.org to Rust@programming.devEnglish · 2 months agomessage-square25fedilinkcross-posted to: lobsters
minus-squareTehPers@beehaw.orglinkfedilinkEnglisharrow-up1·2 months agoThat’s not an alternative, it’s removing let-else entirely. It’s equivalent to this: let i = if let Some(i) = opt_number { i } else { return 0; }; let-else is specifically a feature that allows you to use a refutable pattern to deconstruct a value by providing a diverging else branch.
minus-squaresoc@programming.devlinkfedilinkEnglisharrow-up1·edit-22 months agoRemoving let-else is the whole point of the linked article series: Being able to do to everything Rust does, but without Rust’s zoo of if-then-else, match, if-let, let-else etc.
That’s not an alternative, it’s removing
let-elseentirely. It’s equivalent to this:let-elseis specifically a feature that allows you to use a refutable pattern to deconstruct a value by providing a divergingelsebranch.Removing
let-elseis the whole point of the linked article series:Being able to do to everything Rust does, but without Rust’s zoo of
if-then-else,match,if-let,let-elseetc.