Closed
Description
I have
match token {
DoctypeToken(dt) if mode == Initial => ...,
DoctypeToken(dt) => ...,
TagToken(x) => ...,
CommentToken(x) => ...,
// other cases
This gives
error: cannot bind by-move into a pattern guard
In this situation it should be fine to defer the move until the guard has succeeded.
It's a bit frivolous because I could instead do
match token {
DoctypeToken(dt) => if mode == Initial {
...
} else {
...
},
TagToken(x) => ...,
CommentToken(x) => ...,
// other cases
But I like having all the branching in one construct, especially when I'm implementing a spec which is written that way. And I don't want to add mode
to the match scrutinee because none of the other cases care about it.
See also #4649.