Newtype VariableIterator.

This commit is contained in:
Richard Newman 2017-06-30 09:14:29 -07:00
parent 5fe3d50762
commit 4aa647ddc5

View file

@ -264,6 +264,18 @@ impl Default for ConjoiningClauses {
} }
} }
pub struct VariableIterator<'a>(
::std::collections::btree_map::Keys<'a, Variable, TypedValue>,
);
impl<'a> Iterator for VariableIterator<'a> {
type Item = &'a Variable;
fn next(&mut self) -> Option<&'a Variable> {
self.0.next()
}
}
impl ConjoiningClauses { impl ConjoiningClauses {
/// Construct a new `ConjoiningClauses` with the provided alias counter. This allows a caller /// Construct a new `ConjoiningClauses` with the provided alias counter. This allows a caller
/// to share a counter with an enclosing scope, and to start counting at a particular offset /// to share a counter with an enclosing scope, and to start counting at a particular offset
@ -370,8 +382,8 @@ impl ConjoiningClauses {
} }
/// Return an interator over the variables externally bound to values. /// Return an interator over the variables externally bound to values.
pub fn value_bound_variables(&self) -> ::std::collections::btree_map::Keys<Variable, TypedValue> { pub fn value_bound_variables(&self) -> VariableIterator {
self.value_bindings.keys() VariableIterator(self.value_bindings.keys())
} }
/// Return a set of the variables externally bound to values. /// Return a set of the variables externally bound to values.