From dbbbd220f91b67cfea851ef693e1ccdbc5671aa7 Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Mon, 5 Jun 2017 20:02:41 -0700 Subject: [PATCH] Pre: add helpers to ValueTypeSet. --- query-algebrizer/src/types.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/query-algebrizer/src/types.rs b/query-algebrizer/src/types.rs index e26006c9..0a23802d 100644 --- a/query-algebrizer/src/types.rs +++ b/query-algebrizer/src/types.rs @@ -525,9 +525,27 @@ impl ValueTypeSet { pub fn of_numeric_types() -> ValueTypeSet { ValueTypeSet(EnumSet::of_both(ValueType::Double, ValueType::Long)) } + + /// Return a set containing `Ref` and `Keyword`. + pub fn of_keywords() -> ValueTypeSet { + ValueTypeSet(EnumSet::of_both(ValueType::Ref, ValueType::Keyword)) + } + + /// Return a set containing `Ref` and `Long`. + pub fn of_longs() -> ValueTypeSet { + ValueTypeSet(EnumSet::of_both(ValueType::Ref, ValueType::Long)) + } } impl ValueTypeSet { + pub fn insert(&mut self, vt: ValueType) -> bool { + self.0.insert(vt) + } + + pub fn len(&self) -> usize { + self.0.len() + } + /// Returns a set containing all the types in this set and `other`. pub fn union(&self, other: &ValueTypeSet) -> ValueTypeSet { ValueTypeSet(self.0.union(other.0))