File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 87
87
Less => self . b . next_back ( ) . map ( EitherOrBoth :: Right ) ,
88
88
}
89
89
}
90
+
91
+ fn rfold < B , F > ( self , mut init : B , mut f : F ) -> B
92
+ where
93
+ F : FnMut ( B , Self :: Item ) -> B ,
94
+ {
95
+ let Self { mut a, mut b } = self ;
96
+ let a_len = a. len ( ) ;
97
+ let b_len = b. len ( ) ;
98
+ match a_len. cmp ( & b_len) {
99
+ Equal => { }
100
+ Greater => {
101
+ init = a
102
+ . by_ref ( )
103
+ . rev ( )
104
+ . take ( a_len - b_len)
105
+ . map ( EitherOrBoth :: Left )
106
+ . fold ( init, & mut f)
107
+ }
108
+ Less => {
109
+ init = b
110
+ . by_ref ( )
111
+ . rev ( )
112
+ . take ( b_len - a_len)
113
+ . map ( EitherOrBoth :: Right )
114
+ . fold ( init, & mut f)
115
+ }
116
+ }
117
+ a. rfold ( init, |acc, item_a| {
118
+ f ( acc, EitherOrBoth :: Both ( item_a, b. next_back ( ) . unwrap ( ) ) )
119
+ } )
120
+ }
90
121
}
91
122
92
123
impl < T , U > ExactSizeIterator for ZipLongest < T , U >
You can’t perform that action at this time.
0 commit comments