check if term is empty
This commit is contained in:
parent
96c523ada1
commit
619c2dc3e4
1 changed files with 19 additions and 1 deletions
20
src/sugar.rs
20
src/sugar.rs
|
@ -2,7 +2,7 @@ use {
|
|||
crate::{TypeTerm, TypeID, parser::ParseLadderType}
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub enum SugaredTypeTerm {
|
||||
TypeID(TypeID),
|
||||
Num(i64),
|
||||
|
@ -92,5 +92,23 @@ impl SugaredTypeTerm {
|
|||
).collect()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
match self {
|
||||
SugaredTypeTerm::TypeID(_) => false,
|
||||
SugaredTypeTerm::Num(_) => false,
|
||||
SugaredTypeTerm::Char(_) => false,
|
||||
SugaredTypeTerm::Univ(t) => t.is_empty(),
|
||||
SugaredTypeTerm::Spec(ts) |
|
||||
SugaredTypeTerm::Ladder(ts) |
|
||||
SugaredTypeTerm::Func(ts) |
|
||||
SugaredTypeTerm::Morph(ts) |
|
||||
SugaredTypeTerm::Struct(ts) |
|
||||
SugaredTypeTerm::Enum(ts) |
|
||||
SugaredTypeTerm::Seq(ts) => {
|
||||
ts.iter().fold(true, |s,t|s&&t.is_empty())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue