Skip to main content

nanvm_lib/vm/impls/
partial_eq.rs

1use crate::vm::{IVm, Unpacked, impls::unpack, numeric::Numeric, primitive::Primitive};
2
3impl<A: IVm> PartialEq for Unpacked<A> {
4    fn eq(&self, other: &Self) -> bool {
5        match (self, other) {
6            (Self::Nullish(a), Self::Nullish(b)) => a == b,
7            (Self::Boolean(a), Self::Boolean(b)) => a == b,
8            (Self::Number(a), Self::Number(b)) => a == b,
9            (Self::String(a), Self::String(b)) => a == b,
10            (Self::BigInt(a), Self::BigInt(b)) => a == b,
11            (Self::Object(a), Self::Object(b)) => a == b,
12            (Self::Array(a), Self::Array(b)) => a == b,
13            (Self::Function(a), Self::Function(b)) => a == b,
14            _ => false,
15        }
16    }
17}
18
19impl<A: IVm> PartialEq for Primitive<A> {
20    fn eq(&self, other: &Self) -> bool {
21        unpack(self) == unpack(other)
22    }
23}
24
25impl<A: IVm> PartialEq for Numeric<A> {
26    fn eq(&self, other: &Self) -> bool {
27        unpack(self) == unpack(other)
28    }
29}