-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Allow negation of if let #2616
Copy link
Copy link
Open
Labels
A-control-flowProposals relating to control flow.Proposals relating to control flow.A-expressionsTerm language related proposals & ideasTerm language related proposals & ideasA-syntaxSyntax related proposals & ideasSyntax related proposals & ideasT-langRelevant to the language team, which will review and decide on the RFC.Relevant to the language team, which will review and decide on the RFC.
Metadata
Metadata
Assignees
Labels
A-control-flowProposals relating to control flow.Proposals relating to control flow.A-expressionsTerm language related proposals & ideasTerm language related proposals & ideasA-syntaxSyntax related proposals & ideasSyntax related proposals & ideasT-langRelevant to the language team, which will review and decide on the RFC.Relevant to the language team, which will review and decide on the RFC.
Type
Fields
Give feedbackNo fields configured for issues without a type.
The RFC for
if letwas accepted with the rationale that it lowers the boilerplate and improves ergonomics over the equivalentmatchstatement in certain cases, and I wholeheartedly agree.However, some cases still remain exceedingly awkward; an example of which is attempting to match the "class" of a record
enumvariant, e.g. given the following enum:and an instance
foo: Foo, with behavior predicated onfoonot beingBarand a goal of minimizing nesting/brace creep (e.g. for purposes of an early return), the only choice is to type out something like this:or the equally awkward empty
matchblock:It would be great if this were allowed:
or perhaps a variation on that with slightly less accurate mathematical connotation but far clearer in its intent (you can't miss the
!this time):(although perhaps it is a better idea to tackle this from an entirely different perspective with the goal of greatly increasing overall ergonomics with some form of
isoperator, e.g.if self.integrity_policy is Foo::Bar ..., but that is certainly a much more contentious proposition.)