pub enum BinaryOpKind {
Show 24 variants
Add,
Subtract,
Multiply,
Pow,
Divide,
ExactDivide,
FloorDivide,
Modulo,
Eq,
NotEq,
Lt,
Gt,
LtEq,
GtEq,
And,
Or,
Concat,
SeqConcat,
ApproxEq,
BitXor,
BitAnd,
BitOr,
Shl,
Shr,
}Expand description
Binary operation kinds for imperative expressions.
Variants§
Add
Subtract
Multiply
Pow
a ** b — exponentiation. Integer power is EXACT (promotes to BigInt on
overflow); a Float operand uses powf; a negative integer exponent is a
loud error. Binds tighter than * / %, right-associative.
Divide
ExactDivide
EXACT division — the type-directed sibling of BinaryOpKind::Divide.
Divide floors (7 / 2 → 3, the integer default); ExactDivide keeps the
quotient exact (7 / 2 → 7/2, a Rational). The resolve_divisions pass
rewrites Divide → ExactDivide only where the result flows into a Rational
context, so existing (floor) code is untouched.
FloorDivide
a // b — FLOOR division, rounding toward negative infinity (-7 // 2 → -4).
Distinct from BinaryOpKind::Divide, which truncates toward zero (-7 / 2 → -3); the two agree when the operands share a sign. Exact (promotes to BigInt),
integer-producing, and immune to the resolve_divisions Rational rewrite — the
explicit spelling for “give me the floored integer quotient.”
Modulo
Eq
NotEq
Lt
Gt
LtEq
GtEq
And
Or
Concat
String concatenation (“X combined with Y”)
SeqConcat
Sequence concatenation (“A followed by B”) — merge two sequences into one.
ApproxEq
Tolerant float comparison (“a is approximately b”) — Python-isclose
semantics (rel 1e-9, abs floor 1e-12). == stays IEEE bit-exact;
this is the EXPLICIT spelling for near-equality.
BitXor
Bitwise XOR: x ^ y (the word xor is the English spelling); on
Sets, symmetric difference.
BitAnd
Bitwise AND: x & y; on Sets, intersection.
BitOr
Bitwise OR: x | y; on Sets, union.
Shl
Left shift: “x shifted left by y” → x << y
Shr
Right shift: “x shifted right by y” → x >> y
Trait Implementations§
Source§impl Clone for BinaryOpKind
impl Clone for BinaryOpKind
Source§fn clone(&self) -> BinaryOpKind
fn clone(&self) -> BinaryOpKind
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BinaryOpKind
impl Debug for BinaryOpKind
Source§impl Hash for BinaryOpKind
impl Hash for BinaryOpKind
Source§impl PartialEq for BinaryOpKind
impl PartialEq for BinaryOpKind
Source§fn eq(&self, other: &BinaryOpKind) -> bool
fn eq(&self, other: &BinaryOpKind) -> bool
self and other values to be equal, and is used by ==.