Rewrite Token::is_op.

An exhaustive match is more readable and more future-proof.
This commit is contained in:
Nicholas Nethercote 2022-09-28 11:29:47 +10:00
parent bbb53bf772
commit 40e4827fd2

View File

@ -345,17 +345,14 @@ pub fn uninterpolated_span(&self) -> Span {
} }
pub fn is_op(&self) -> bool { pub fn is_op(&self) -> bool {
!matches!( match self.kind {
self.kind, Eq | Lt | Le | EqEq | Ne | Ge | Gt | AndAnd | OrOr | Not | Tilde | BinOp(_)
OpenDelim(..) | BinOpEq(_) | At | Dot | DotDot | DotDotDot | DotDotEq | Comma | Semi | Colon
| CloseDelim(..) | ModSep | RArrow | LArrow | FatArrow | Pound | Dollar | Question | SingleQuote => true,
| Literal(..)
| DocComment(..) OpenDelim(..) | CloseDelim(..) | Literal(..) | DocComment(..) | Ident(..)
| Ident(..) | Lifetime(..) | Interpolated(..) | Eof => false,
| Lifetime(..) }
| Interpolated(..)
| Eof
)
} }
pub fn is_like_plus(&self) -> bool { pub fn is_like_plus(&self) -> bool {