pub enum BinaryOp {
Show 18 variants
Mul,
Div,
Rem,
Add,
Sub,
Shl,
Shr,
Lt,
Gt,
Le,
Ge,
Eq,
Ne,
BitAnd,
BitXor,
BitOr,
LogAnd,
LogOr,
}Expand description
An operator with two operands.
The comma operator is not here; it is Expr::Comma. Assignment is not here either, and
the operator part of a compound assignment reuses this enum, which is why the values that
cannot appear in one (BinaryOp::LogAnd and the comparisons) are simply never built by
the parser rather than being a second enum.
Variants§
Mul
*.
Div
/.
Rem
%.
Add
+.
Sub
-.
Shl
<<.
Shr
>>.
Lt
<.
Gt
>.
Le
<=.
Ge
>=.
Eq
==.
Ne
!=.
BitAnd
&.
BitXor
^.
BitOr
|.
LogAnd
&&, which does not evaluate its right operand unless it has to.
LogOr
||, likewise.
Implementations§
Source§impl BinaryOp
impl BinaryOp
Sourcepub const fn is_short_circuit(self) -> bool
pub const fn is_short_circuit(self) -> bool
Whether the operator sequences its left operand before its right, which only the two short-circuiting ones do.
Sourcepub const fn is_comparison(self) -> bool
pub const fn is_comparison(self) -> bool
Whether the operator is one of the six relational and equality ones.
What the six have in common is the answer rather than the operands: it is one bit, and
C makes it an int holding zero or one. Everything that has to treat them alike asks
this rather than spelling the six out again.