@@ -602,6 +602,24 @@ where
602
602
BothBackward | Back => self . b . get ( ) ,
603
603
}
604
604
}
605
+
606
+ #[ inline]
607
+ fn fold < Acc , F > ( self , init : Acc , mut f : F ) -> Acc
608
+ where
609
+ Self : Sized ,
610
+ F : FnMut ( Acc , & Self :: Item ) -> Acc ,
611
+ {
612
+ let mut accum = init;
613
+ match self . state {
614
+ ChainState :: Back => { }
615
+ _ => accum = self . a . fold ( accum, & mut f) ,
616
+ }
617
+ match self . state {
618
+ ChainState :: Front => { }
619
+ _ => accum = self . b . fold ( accum, & mut f) ,
620
+ }
621
+ accum
622
+ }
605
623
}
606
624
607
625
impl < A , B > DoubleEndedStreamingIterator for Chain < A , B >
@@ -626,6 +644,24 @@ where
626
644
Back => self . b . advance_back ( ) ,
627
645
}
628
646
}
647
+
648
+ #[ inline]
649
+ fn rfold < Acc , F > ( self , init : Acc , mut f : F ) -> Acc
650
+ where
651
+ Self : Sized ,
652
+ F : FnMut ( Acc , & Self :: Item ) -> Acc ,
653
+ {
654
+ let mut accum = init;
655
+ match self . state {
656
+ ChainState :: Front => { }
657
+ _ => accum = self . b . rfold ( accum, & mut f) ,
658
+ }
659
+ match self . state {
660
+ ChainState :: Back => { }
661
+ _ => accum = self . a . rfold ( accum, & mut f) ,
662
+ }
663
+ accum
664
+ }
629
665
}
630
666
631
667
/// A normal, non-streaming, iterator which converts the elements of a streaming iterator into owned
0 commit comments