File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed
Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -175,23 +175,22 @@ where
175175 ) -> ( u32 , Counter < char , u32 > , Vec < & ' a CC > ) {
176176 let mut letter_counter: Counter < char , u32 > = Counter :: new ( ) ;
177177
178- let ( words_vec, additional_count) : ( Vec < & ' a CC > , usize ) = if self . letters_in_pattern_have_no_other_occurrences {
179- let mut words = words. inspect ( |word| letter_counter. update ( word. iter_chars ( ) . unique ( ) ) ) ;
180-
181- if let Some ( n) = max_words_to_collect {
182- ( words. by_ref ( ) . take ( n) . collect ( ) , words. count ( ) )
178+ let update_counter: fn ( & mut Counter < char , u32 > , & CC ) =
179+ if self . letters_in_pattern_have_no_other_occurrences {
180+ |counter, word| counter. update ( word. iter_chars ( ) . unique ( ) )
183181 } else {
184- ( words. collect ( ) , 0 )
185- }
186- } else {
187- let mut words = words. inspect ( |word| letter_counter. update ( word. iter_chars ( ) ) ) ;
182+ |counter, word| counter. update ( word. iter_chars ( ) )
183+ } ;
184+
185+ let mut words =
186+ words. inspect ( |word| update_counter ( & mut letter_counter, word) ) ;
188187
188+ let ( words_vec, additional_count) : ( Vec < & ' a CC > , usize ) =
189189 if let Some ( n) = max_words_to_collect {
190190 ( words. by_ref ( ) . take ( n) . collect ( ) , words. count ( ) )
191191 } else {
192192 ( words. collect ( ) , 0 )
193- }
194- } ;
193+ } ;
195194
196195 let words_count = u32:: try_from ( additional_count + words_vec. len ( ) )
197196 . unwrap_or ( u32:: MAX ) ;
You can’t perform that action at this time.
0 commit comments