Closed tetotechy closed 1 month ago
[^ch]
is equivalent to [^_]
and will always fail -- that expands to basically
match next_char {
ch => return failure
_ => next
}
^
just swaps the outcome of the match arms. ch
is a pattern that matches any character and binds a new variable, though you can't access that variable because that arm immediately backtracks. It doesn't compare it to the outer ch
variable, just like [ch]
is different from [c if c == ch]
.
It seems to me that
works whereas
doesn't (it compiles but the behaviour is different, possibly wrong imo), correct? Is there a reason for that? Thanks.