From 4aa647ddc5791f9ac5c2a7877de483e9ae8dd187 Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Fri, 30 Jun 2017 09:14:29 -0700 Subject: [PATCH] Newtype VariableIterator. --- query-algebrizer/src/clauses/mod.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/query-algebrizer/src/clauses/mod.rs b/query-algebrizer/src/clauses/mod.rs index b066be62..050b3400 100644 --- a/query-algebrizer/src/clauses/mod.rs +++ b/query-algebrizer/src/clauses/mod.rs @@ -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 { /// 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 @@ -370,8 +382,8 @@ impl ConjoiningClauses { } /// Return an interator over the variables externally bound to values. - pub fn value_bound_variables(&self) -> ::std::collections::btree_map::Keys { - self.value_bindings.keys() + pub fn value_bound_variables(&self) -> VariableIterator { + VariableIterator(self.value_bindings.keys()) } /// Return a set of the variables externally bound to values.