From 6061c9600d1c306cefdcb4a67e5ef10a2cc60a30 Mon Sep 17 00:00:00 2001 From: Philippe-Cholet Date: Thu, 31 Aug 2023 16:33:27 +0200 Subject: [PATCH] Unalias `MergeBy` --- src/merge_join.rs | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/merge_join.rs b/src/merge_join.rs index 5a7ba59c1..be2df798c 100644 --- a/src/merge_join.rs +++ b/src/merge_join.rs @@ -47,14 +47,19 @@ pub fn merge(i: I, j: J) -> Merge<::IntoIter, = InternalMergeJoinBy; +#[must_use = "iterator adaptors are lazy and do nothing unless consumed"] +pub struct MergeBy { + left: PutBack>, + right: PutBack>, + cmp_fn: F, +} /// Create a `MergeBy` iterator. pub fn merge_by_new(a: I, b: J, cmp: F) -> MergeBy where I: IntoIterator, J: IntoIterator, { - InternalMergeJoinBy { + MergeBy { left: put_back(a.into_iter().fuse()), right: put_back(b.into_iter().fuse()), cmp_fn: cmp, @@ -70,7 +75,7 @@ pub fn merge_join_by(left: I, right: J, cmp_fn: F) J: IntoIterator, F: FnMut(&I::Item, &J::Item) -> T, { - InternalMergeJoinBy { + MergeBy { left: put_back(left.into_iter().fuse()), right: put_back(right.into_iter().fuse()), cmp_fn: MergeFuncLR(cmp_fn, PhantomData), @@ -80,14 +85,7 @@ pub fn merge_join_by(left: I, right: J, cmp_fn: F) /// An iterator adaptor that merge-joins items from the two base iterators in ascending order. /// /// See [`.merge_join_by()`](crate::Itertools::merge_join_by) for more information. -pub type MergeJoinBy = InternalMergeJoinBy::Item, ::Item>>::T>>; - -#[must_use = "iterator adaptors are lazy and do nothing unless consumed"] -pub struct InternalMergeJoinBy { - left: PutBack>, - right: PutBack>, - cmp_fn: F, -} +pub type MergeJoinBy = MergeBy::Item, ::Item>>::T>>; #[derive(Clone, Debug)] pub struct MergeFuncLR(F, PhantomData); @@ -206,7 +204,7 @@ impl OrderingOrBool for MergeLte { } } -impl Clone for InternalMergeJoinBy +impl Clone for MergeBy where I: Iterator, J: Iterator, PutBack>: Clone, @@ -216,16 +214,16 @@ impl Clone for InternalMergeJoinBy clone_fields!(left, right, cmp_fn); } -impl fmt::Debug for InternalMergeJoinBy +impl fmt::Debug for MergeBy where I: Iterator + fmt::Debug, I::Item: fmt::Debug, J: Iterator + fmt::Debug, J::Item: fmt::Debug, { - debug_fmt_fields!(InternalMergeJoinBy, left, right); + debug_fmt_fields!(MergeBy, left, right); } -impl Iterator for InternalMergeJoinBy +impl Iterator for MergeBy where I: Iterator, J: Iterator, F: OrderingOrBool, @@ -328,7 +326,7 @@ impl Iterator for InternalMergeJoinBy } } -impl FusedIterator for InternalMergeJoinBy +impl FusedIterator for MergeBy where I: Iterator, J: Iterator,