Skip to content

if let construction? #109

@dessalines

Description

@dessalines

I'm not sure if this would be possible in typescript.

In addition to match, rust also has if let Some(X) = an_opt_var { ....

This is really useful, since often the None case isn't used / ignored.

It's possible to do if (opt.isSome()) { let x = opt.unwrap()... but that's less compiler-checked, and it requires an unsafe unwrap.

I'd like this a lot since my lemmy-ui codebase has tons of these verbose .match whilst ignoring the none case, all over the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions