summary refs log tree commit diff stats
path: root/src/vm.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/vm.rs')
-rw-r--r--src/vm.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/vm.rs b/src/vm.rs
index 595fac1..5b27a36 100644
--- a/src/vm.rs
+++ b/src/vm.rs
@@ -1,3 +1,4 @@
+use crate::KVPair;
 use crate::PatternTypes;
 use crate::Predicate;
 use crate::errors::MatchError;
@@ -7,7 +8,7 @@ use std::marker::PhantomData;
 
 pub(crate) const MAX_CALLS: usize = 250;
 
-type Matches<'a, 'b, T> = BTreeMap<&'a str, (&'b <T as PatternTypes>::Value, &'b <T as PatternTypes>::Value)>;
+type Matches<'a, 'b, T> = BTreeMap<&'a str, KVPair<'b, T>>;
 
 // TODO: use a builder for this?
 /// The constant pool for a pattern.
@@ -95,7 +96,7 @@ impl<'a, 'b, T: PatternTypes> Frame<'a, 'b, T> {
 enum HolderState<'a, 'b, T: PatternTypes> {
     EmptyKey,
     EmptySubtree,
-    Key((&'b T::Value, &'b T::Value)),
+    Key(KVPair<'b, T>),
     Subtree(Matches<'a, 'b, T>, &'b T::Value),
 }
 
@@ -136,7 +137,7 @@ struct Holder<'a, 'b, T: PatternTypes> {
      name: Option<&'a str>,
      value: HolderState<'a, 'b, T>,
      parent: Option<&'b T::Value>,
-     iterator: Box<dyn Iterator<Item=(&'b T::Value, &'b T::Value)> + 'b>,
+     iterator: Box<dyn Iterator<Item=KVPair<'b, T>> + 'b>,
      filters: Vec<Box<dyn for<'c> Fn(&'c mut HolderState<'a, 'b, T>) + 'a>>,
 }
 
@@ -262,7 +263,7 @@ impl<'a, 'b, T: PatternTypes> Matcher<'a, 'b, T> {
 }
 
 impl<'a, 'b, T: PatternTypes> Iterator for Matcher<'a, 'b, T> {
-    type Item = Result<BTreeMap<&'a str, (&'b T::Value, &'b T::Value)>, MatchError>;
+    type Item = Result<BTreeMap<&'a str, KVPair<'b, T>>, MatchError>;
 
     fn next(&mut self) -> Option<Self::Item> {
         while !self.frame.path.is_empty() {