make any match any type

This commit is contained in:
2024-10-16 17:10:27 -04:00
parent 329af77ff4
commit 8c7993bacc

View File

@@ -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 {