From adf6b9f7be9a59be129869f4c63d33b10c80e23f Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Sat, 16 Jan 2021 10:12:13 -0300 Subject: Workaround lack of GATs --- src/vm.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/vm.rs') 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 ::Value, &'b ::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 + 'b>, + iterator: Box> + 'b>, filters: Vec 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, MatchError>; + type Item = Result>, MatchError>; fn next(&mut self) -> Option { while !self.frame.path.is_empty() { -- cgit 1.4.1