Deduplicate is_comparison impl between BinOpKind and AssocOp

This commit is contained in:
Oli Scherer 2024-04-10 10:53:24 +00:00
parent bb78dba64c
commit 07a9854b5c

View File

@ -920,14 +920,8 @@ pub fn is_lazy(&self) -> bool {
matches!(self, BinOpKind::And | BinOpKind::Or) matches!(self, BinOpKind::And | BinOpKind::Or)
} }
pub fn is_comparison(&self) -> bool { pub fn is_comparison(self) -> bool {
use BinOpKind::*; crate::util::parser::AssocOp::from_ast_binop(self).is_comparison()
// Note for developers: please keep this match exhaustive;
// we want compilation to fail if another variant is added.
match *self {
Eq | Lt | Le | Ne | Gt | Ge => true,
And | Or | Add | Sub | Mul | Div | Rem | BitXor | BitAnd | BitOr | Shl | Shr => false,
}
} }
/// Returns `true` if the binary operator takes its arguments by value. /// Returns `true` if the binary operator takes its arguments by value.