@@ -884,6 +884,15 @@ where
884
884
fn next_back ( & mut self ) -> Option < I :: Item > {
885
885
self . 0 . next_back ( ) . map ( Clone :: clone)
886
886
}
887
+
888
+ #[ inline]
889
+ fn rfold < Acc , Fold > ( self , init : Acc , mut f : Fold ) -> Acc
890
+ where
891
+ Self : Sized ,
892
+ Fold : FnMut ( Acc , Self :: Item ) -> Acc ,
893
+ {
894
+ self . 0 . rfold ( init, move |acc, item| f ( acc, item. clone ( ) ) )
895
+ }
887
896
}
888
897
889
898
/// A streaming iterator which filters the elements of a streaming iterator with a predicate.
@@ -1313,6 +1322,19 @@ where
1313
1322
1314
1323
None
1315
1324
}
1325
+
1326
+ #[ inline]
1327
+ fn rfold < Acc , Fold > ( self , init : Acc , mut f : Fold ) -> Acc
1328
+ where
1329
+ Self : Sized ,
1330
+ Fold : FnMut ( Acc , Self :: Item ) -> Acc ,
1331
+ {
1332
+ let mut map = self . f ;
1333
+ self . it . rfold ( init, move |acc, item| match map ( item) {
1334
+ Some ( mapped) => f ( acc, mapped) ,
1335
+ None => acc,
1336
+ } )
1337
+ }
1316
1338
}
1317
1339
1318
1340
#[ derive( Copy , Clone , Debug ) ]
@@ -1705,6 +1727,16 @@ where
1705
1727
fn next_back ( & mut self ) -> Option < Self :: Item > {
1706
1728
self . it . next_back ( ) . map ( & mut self . f )
1707
1729
}
1730
+
1731
+ #[ inline]
1732
+ fn rfold < Acc , Fold > ( self , init : Acc , mut f : Fold ) -> Acc
1733
+ where
1734
+ Self : Sized ,
1735
+ Fold : FnMut ( Acc , Self :: Item ) -> Acc ,
1736
+ {
1737
+ let mut map = self . f ;
1738
+ self . it . rfold ( init, move |acc, item| f ( acc, map ( item) ) )
1739
+ }
1708
1740
}
1709
1741
1710
1742
/// A regular, non-streaming iterator which transforms the elements of a mutable streaming iterator.
@@ -1751,6 +1783,16 @@ where
1751
1783
fn next_back ( & mut self ) -> Option < Self :: Item > {
1752
1784
self . it . next_back_mut ( ) . map ( & mut self . f )
1753
1785
}
1786
+
1787
+ #[ inline]
1788
+ fn rfold < Acc , Fold > ( self , init : Acc , mut f : Fold ) -> Acc
1789
+ where
1790
+ Self : Sized ,
1791
+ Fold : FnMut ( Acc , Self :: Item ) -> Acc ,
1792
+ {
1793
+ let mut map = self . f ;
1794
+ self . it . rfold_mut ( init, move |acc, item| f ( acc, map ( item) ) )
1795
+ }
1754
1796
}
1755
1797
1756
1798
/// A streaming iterator which transforms the elements of a streaming iterator.
@@ -1849,6 +1891,15 @@ where
1849
1891
fn next_back ( & mut self ) -> Option < <I :: Item as ToOwned >:: Owned > {
1850
1892
self . 0 . next_back ( ) . map ( ToOwned :: to_owned)
1851
1893
}
1894
+
1895
+ #[ inline]
1896
+ fn rfold < Acc , Fold > ( self , init : Acc , mut f : Fold ) -> Acc
1897
+ where
1898
+ Self : Sized ,
1899
+ Fold : FnMut ( Acc , Self :: Item ) -> Acc ,
1900
+ {
1901
+ self . 0 . rfold ( init, move |acc, item| f ( acc, item. to_owned ( ) ) )
1902
+ }
1852
1903
}
1853
1904
1854
1905
/// A streaming iterator which skips a number of elements in a streaming iterator.
0 commit comments