From 11c793dd2a15fc22e5768501a85d3909a4dbabb1 Mon Sep 17 00:00:00 2001 From: rvcas Date: Tue, 13 Dec 2022 15:02:46 -0500 Subject: [PATCH] feat(Type): add is_option method --- crates/lang/src/tipo.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/lang/src/tipo.rs b/crates/lang/src/tipo.rs index 4a16a4a0..6b457ff3 100644 --- a/crates/lang/src/tipo.rs +++ b/crates/lang/src/tipo.rs @@ -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(),