Deduplicate is_comparison
impl between BinOpKind
and AssocOp
This commit is contained in:
parent
bb78dba64c
commit
07a9854b5c
@ -920,14 +920,8 @@ pub fn is_lazy(&self) -> bool {
|
||||
matches!(self, BinOpKind::And | BinOpKind::Or)
|
||||
}
|
||||
|
||||
pub fn is_comparison(&self) -> bool {
|
||||
use BinOpKind::*;
|
||||
// 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,
|
||||
}
|
||||
pub fn is_comparison(self) -> bool {
|
||||
crate::util::parser::AssocOp::from_ast_binop(self).is_comparison()
|
||||
}
|
||||
|
||||
/// Returns `true` if the binary operator takes its arguments by value.
|
||||
|
Loading…
Reference in New Issue
Block a user