nanvm_lib/vm/bigint/partial_eq.rs
1use crate::vm::{BigInt, IVm};
2use std::cmp::Ordering;
3
4/// Equality is defined by [`Ord`] (in `cmp.rs`), the single owner of how two
5/// `BigInt`s relate, so `a == b` holds exactly when `a.cmp(&b) == Equal` by
6/// construction rather than by two code paths happening to agree.
7///
8/// Invariant: both operands are normalized — no leading (most-significant)
9/// zero words, and zero is always `Sign::Positive` with no words (no negative
10/// zero). `Ord` relies on it and panics on a non-normalized operand, which
11/// only `unchecked_new` can build.
12impl<A: IVm> PartialEq for BigInt<A> {
13 fn eq(&self, other: &Self) -> bool {
14 self.cmp(other) == Ordering::Equal
15 }
16}
17
18impl<A: IVm> Eq for BigInt<A> {}