Pre: add helpers to ValueTypeSet.

This commit is contained in:
Richard Newman 2017-06-05 20:02:41 -07:00 committed by Richard Newman
parent 9a12ced317
commit dbbbd220f9

View file

@ -525,9 +525,27 @@ impl ValueTypeSet {
pub fn of_numeric_types() -> ValueTypeSet { pub fn of_numeric_types() -> ValueTypeSet {
ValueTypeSet(EnumSet::of_both(ValueType::Double, ValueType::Long)) 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 { 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`. /// Returns a set containing all the types in this set and `other`.
pub fn union(&self, other: &ValueTypeSet) -> ValueTypeSet { pub fn union(&self, other: &ValueTypeSet) -> ValueTypeSet {
ValueTypeSet(self.0.union(other.0)) ValueTypeSet(self.0.union(other.0))