diff --git a/src/lib.rs b/src/lib.rs index 3020752..628ec7f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,7 @@ use std::fmt::Display; use std::io::{Write, Read, BufRead}; use std::fmt; -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug)] pub enum Type { Float, Int, @@ -22,6 +22,18 @@ pub enum Type { Any, } +impl PartialEq for Type { + fn eq(&self, other: &Type) -> bool { + match (self, other) { + (Self::Any, _) => true, + (_, Self::Any) => true, + (Self::Array(l0), Self::Array(r0)) => l0 == r0, + (Self::Function(l0), Self::Function(r0)) => l0 == r0, + _ => core::mem::discriminant(self) == core::mem::discriminant(other), + } + } +} + impl Display for Type { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", match self {