Skip to content

Commit

Permalink
revset: simplify type constraints on combination iterators
Browse files Browse the repository at this point in the history
Just a minor cleanup to remove lifetime parameter from the types. I tried to
reimplement them by using itertools, but I couldn't find a simple way to
encode short-circuiting at the end of either left or right iterator.
  • Loading branch information
yuja committed Dec 15, 2023
1 parent 00a3213 commit f31d92f
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions lib/src/default_revset_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,17 +404,15 @@ where
}
}

struct UnionRevsetIterator<
'index,
I1: Iterator<Item = IndexEntry<'index>>,
I2: Iterator<Item = IndexEntry<'index>>,
> {
struct UnionRevsetIterator<I1: Iterator, I2: Iterator> {
iter1: Peekable<I1>,
iter2: Peekable<I2>,
}

impl<'index, I1: Iterator<Item = IndexEntry<'index>>, I2: Iterator<Item = IndexEntry<'index>>>
Iterator for UnionRevsetIterator<'index, I1, I2>
impl<'index, I1, I2> Iterator for UnionRevsetIterator<I1, I2>
where
I1: Iterator<Item = IndexEntry<'index>>,
I2: Iterator<Item = IndexEntry<'index>>,
{
type Item = IndexEntry<'index>;

Expand Down Expand Up @@ -478,17 +476,15 @@ where
}
}

struct IntersectionRevsetIterator<
'index,
I1: Iterator<Item = IndexEntry<'index>>,
I2: Iterator<Item = IndexEntry<'index>>,
> {
struct IntersectionRevsetIterator<I1: Iterator, I2: Iterator> {
iter1: Peekable<I1>,
iter2: Peekable<I2>,
}

impl<'index, I1: Iterator<Item = IndexEntry<'index>>, I2: Iterator<Item = IndexEntry<'index>>>
Iterator for IntersectionRevsetIterator<'index, I1, I2>
impl<'index, I1, I2> Iterator for IntersectionRevsetIterator<I1, I2>
where
I1: Iterator<Item = IndexEntry<'index>>,
I2: Iterator<Item = IndexEntry<'index>>,
{
type Item = IndexEntry<'index>;

Expand Down Expand Up @@ -564,17 +560,15 @@ where
}
}

struct DifferenceRevsetIterator<
'index,
I1: Iterator<Item = IndexEntry<'index>>,
I2: Iterator<Item = IndexEntry<'index>>,
> {
struct DifferenceRevsetIterator<I1: Iterator, I2: Iterator> {
iter1: Peekable<I1>,
iter2: Peekable<I2>,
}

impl<'index, I1: Iterator<Item = IndexEntry<'index>>, I2: Iterator<Item = IndexEntry<'index>>>
Iterator for DifferenceRevsetIterator<'index, I1, I2>
impl<'index, I1, I2> Iterator for DifferenceRevsetIterator<I1, I2>
where
I1: Iterator<Item = IndexEntry<'index>>,
I2: Iterator<Item = IndexEntry<'index>>,
{
type Item = IndexEntry<'index>;

Expand Down

0 comments on commit f31d92f

Please sign in to comment.