diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2021-01-16 10:12:13 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2021-01-16 10:12:53 -0300 |
commit | adf6b9f7be9a59be129869f4c63d33b10c80e23f (patch) | |
tree | 3b4eb41861b9d52310045b23dcd85ef52adb3fa7 /src/vm.rs | |
parent | c0b4a8a326a320ac33c5d9d6bac2f7ea7eb703ce (diff) |
Workaround lack of GATs
Diffstat (limited to 'src/vm.rs')
-rw-r--r-- | src/vm.rs | 9 |
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() { |