Skip to content

Conversation

@hanbings-agent
Copy link
Owner

Introduces if <expr> matches <pat> as syntactic sugar for if let <pat> = <expr>.

This change provides a more fluent and natural syntax for conditional pattern matching, offering an alternative to if let.

The new syntax if <expr> matches <pat> is parsed into the same ExprKind::Let(<pat>, <expr>, ..) AST node as if let <pat> = <expr>, ensuring identical semantics and no breaking changes. This special parsing for matches only occurs within if/while conditions (when Restrictions::ALLOW_LET is active) to avoid conflicts with matches used as a regular identifier.

A UI test has been added to cover the new syntax and confirm that matches as an identifier remains valid in other contexts.


Open in Cursor Open in Web

This adds sugar for `if let` expressions, allowing `if opt matches Some(x)`.

Co-authored-by: agent <agent@hanbings.io>
@cursor
Copy link

cursor bot commented Dec 22, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants