Skip to main content

equality

Function equality 

Source
pub fn equality(
    left: &RuntimeValue,
    right: &RuntimeValue,
    negate: bool,
) -> Result<RuntimeValue, String>
Expand description

Value equality for the equals/== operator, set/list membership, and map keys (RuntimeValue’s PartialEq delegates here — ONE equality).

  • Floats compare by IEEE == (NaN != NaN, -0.0 == 0.0) — identical to what compiled Rust emits, on every engine.
  • Cross-type numeric equality is EXACT (mathematical value, never a lossy cast): 1 == 1.0, but 9007199254740993 != 9007199254740993.0 because that float literal IS 2^53. Coheres with compare and with the unified numeric hash (base::numeric).
  • Collections, tuples, and structs compare STRUCTURALLY (same shape, all parts equal), with an Rc identity fast path and a depth cap against cyclic values.
  • Decimal/Complex/Modular keep their documented within-type equality (they have no cross-type ordering, so there is no coherence to break). left = right (or ≠ when negate) as a program asks it: decided exactly where a theorem decides it, residue-dependent where the answer depends on ⌈1/dt⌉, and a loud error where two computable reals agree to the budget and nothing decides them. Every other value compares by values_equal.