feat(Type): add is_option method

This commit is contained in:
rvcas
2022-12-13 15:02:46 -05:00
committed by KtorZ
parent 8393d8555c
commit 11c793dd2a

View File

@@ -135,6 +135,14 @@ impl Type {
}
}
pub fn is_option(&self) -> bool {
match self {
Self::App { module, name, .. } if "Option" == name && module.is_empty() => true,
Self::Var { tipo } => tipo.borrow().is_option(),
_ => false,
}
}
pub fn is_map(&self) -> bool {
match self {
Self::App {
@@ -416,6 +424,13 @@ impl TypeVar {
}
}
pub fn is_option(&self) -> bool {
match self {
Self::Link { tipo } => tipo.is_option(),
_ => false,
}
}
pub fn is_map(&self) -> bool {
match self {
Self::Link { tipo } => tipo.is_map(),