▲ 29 ▼ things rust shipped without (2015) (graydon2.dreamwidth.org) submitted 1 year ago by azdle@news.idlestate.org to c/rust@programming.dev 23 comments fedilink hide all child comments
[–] soc@programming.dev 1 point 1 year ago* (last edited 1 year ago) (2 children) I don't think the alternative to let-else is too bad. permalink fedilink source parent hideshow 2 child comments replies: [–] TehPers@beehaw.org 1 point 1 year ago (1 child) That'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. permalink fedilink source parent hideshow 1 child comment replies: [–] soc@programming.dev 1 point 1 year ago* (last edited 1 year ago) Removing 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. permalink fedilink source parent
[–] TehPers@beehaw.org 1 point 1 year ago (1 child) That'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. permalink fedilink source parent hideshow 1 child comment replies: [–] soc@programming.dev 1 point 1 year ago* (last edited 1 year ago) Removing 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. permalink fedilink source parent
[–] soc@programming.dev 1 point 1 year ago* (last edited 1 year ago) Removing 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. permalink fedilink source parent