From 91e56c7f2f4410e8985dbb573564938075d182a6 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Wed, 15 Feb 2023 21:02:47 -0800 Subject: [PATCH] revset: add type parameters to remaining iterator adapters This is another step towards removing `RevsetIterator`. These types are private, so someone using the library can't accidentally create a `UnionRevsetIterator` with inputs in different order, for example. --- lib/src/revset.rs | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/lib/src/revset.rs b/lib/src/revset.rs index 253b74158..e6764d728 100644 --- a/lib/src/revset.rs +++ b/lib/src/revset.rs @@ -1769,12 +1769,18 @@ impl<'index> ToPredicateFn<'index> for UnionRevset<'index> { } } -struct UnionRevsetIterator<'revset, 'index> { - iter1: Peekable>, - iter2: Peekable>, +struct UnionRevsetIterator< + 'index, + I1: Iterator>, + I2: Iterator>, +> { + iter1: Peekable, + iter2: Peekable, } -impl<'revset, 'index> Iterator for UnionRevsetIterator<'revset, 'index> { +impl<'index, I1: Iterator>, I2: Iterator>> + Iterator for UnionRevsetIterator<'index, I1, I2> +{ type Item = IndexEntry<'index>; fn next(&mut self) -> Option { @@ -1815,12 +1821,18 @@ impl<'index> ToPredicateFn<'index> for IntersectionRevset<'index> { } } -struct IntersectionRevsetIterator<'revset, 'index> { - iter1: Peekable>, - iter2: Peekable>, +struct IntersectionRevsetIterator< + 'index, + I1: Iterator>, + I2: Iterator>, +> { + iter1: Peekable, + iter2: Peekable, } -impl<'revset, 'index> Iterator for IntersectionRevsetIterator<'revset, 'index> { +impl<'index, I1: Iterator>, I2: Iterator>> + Iterator for IntersectionRevsetIterator<'index, I1, I2> +{ type Item = IndexEntry<'index>; fn next(&mut self) -> Option { @@ -1874,12 +1886,18 @@ impl<'index> ToPredicateFn<'index> for DifferenceRevset<'index> { } } -struct DifferenceRevsetIterator<'revset, 'index> { - iter1: Peekable>, - iter2: Peekable>, +struct DifferenceRevsetIterator< + 'index, + I1: Iterator>, + I2: Iterator>, +> { + iter1: Peekable, + iter2: Peekable, } -impl<'revset, 'index> Iterator for DifferenceRevsetIterator<'revset, 'index> { +impl<'index, I1: Iterator>, I2: Iterator>> + Iterator for DifferenceRevsetIterator<'index, I1, I2> +{ type Item = IndexEntry<'index>; fn next(&mut self) -> Option {