@@ -605,31 +605,6 @@ impl<I, J, F> Iterator for MergeBy<I, J, F>
605
605
}
606
606
}
607
607
608
- impl < I , F , T > Coalesce < I , F , T >
609
- where I : Iterator ,
610
- F : CoalescePredicate < I :: Item , T > ,
611
- {
612
- fn next_with ( & mut self ) -> Option < T > {
613
- // this fuses the iterator
614
- let mut last = match self . last . take ( ) {
615
- None => return None ,
616
- Some ( x) => x,
617
- } ;
618
- for next in & mut self . iter {
619
- match self . f . coalesce_pair ( last, next) {
620
- Ok ( joined) => last = joined,
621
- Err ( ( last_, next_) ) => {
622
- self . last = Some ( next_) ;
623
- return Some ( last_) ;
624
- }
625
- }
626
- }
627
-
628
- Some ( last)
629
- }
630
-
631
- }
632
-
633
608
/// An iterator adaptor that may join together adjacent elements.
634
609
///
635
610
/// See [`.coalesce()`](../trait.Itertools.html#method.coalesce) for more information.
@@ -685,7 +660,21 @@ impl<I, F, T> Iterator for Coalesce<I, F, T>
685
660
type Item = T ;
686
661
687
662
fn next ( & mut self ) -> Option < Self :: Item > {
688
- self . next_with ( )
663
+ // this fuses the iterator
664
+ let mut last = match self . last . take ( ) {
665
+ None => return None ,
666
+ Some ( x) => x,
667
+ } ;
668
+ for next in & mut self . iter {
669
+ match self . f . coalesce_pair ( last, next) {
670
+ Ok ( joined) => last = joined,
671
+ Err ( ( last_, next_) ) => {
672
+ self . last = Some ( next_) ;
673
+ return Some ( last_) ;
674
+ }
675
+ }
676
+ }
677
+ Some ( last)
689
678
}
690
679
691
680
fn size_hint ( & self ) -> ( usize , Option < usize > ) {
0 commit comments