Pre: add some 'am I a pattern?' helper predicates to clause types.

This commit is contained in:
Richard Newman 2017-03-27 20:53:08 -07:00
parent d2e6b767c6
commit 439f3a2283

View file

@ -504,12 +504,31 @@ pub enum UnifyVars {
Explicit(Vec<Variable>),
}
impl WhereClause {
pub fn is_pattern(&self) -> bool {
match self {
&WhereClause::Pattern(_) => true,
_ => false,
}
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum OrWhereClause {
Clause(WhereClause),
And(Vec<WhereClause>),
}
impl OrWhereClause {
pub fn is_pattern_or_patterns(&self) -> bool {
match self {
&OrWhereClause::Clause(WhereClause::Pattern(_)) => true,
&OrWhereClause::And(ref clauses) => clauses.iter().all(|clause| clause.is_pattern()),
_ => false,
}
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct OrJoin {
pub unify_vars: UnifyVars,