So, I do think that something like matches
makes sense. I'm not suggesting we shouldn't do it. But we already have if let
, and extending that to allow chaining would be an intuitive extension for people who are already used to if let
; I think we should do that regardless. Then, we could define matches
as a trivial desugaring, with if let
taking care of details like the scopes of bindings.
I wouldn't want to have matches
without having bindings, because it's incredibly useful to write things like if expr matches Some(x) && another_expr(x)
. That has all the same issues as if let
, in terms of the scopes of the bindings. I think we should have both, and I think we should define the semantics only once.