The matches operator
Syntax
matches_expr ::= spec_expr matches pattern && spec_expr
| spec_expr matches pattern ==> spec_expr
Typing
The left-hand side should be of a type that matches the pattern, while the right-hand
side should have type bool.
The right-hand side may reference variables bound by the pattern.
The matches_expr as a whole has type bool.
Semantics
The “matches-and” expression expr matches pat && condition is equivalent to:
match expr {
pat => condition,
_ => false,
}
The “matches-implies” expression expr matches pat ==> condition is equivalent to:
match expr {
pat => condition,
_ => true,
}