compare against accumulator rather than init value

This commit is contained in:
Vignesh Sarma K (വിഘ്നേഷ് ശ൪മ കെ)
2018-08-27 22:16:47 +05:30
parent 835cdc2fe8
commit 46decdb0ea

View File

@@ -143,7 +143,7 @@ fn select_best_fragment_combination<'a>(fragments: Vec<FragmentCandidate>,
text: &'a str,) -> Snippet {
if let Some(init) = fragments.iter().nth(0) {
let fragment = fragments.iter().skip(1).fold(init, |acc, item| {
if item.score > init.score { item } else { init }
if item.score > acc.score { item } else { acc }
});
let fragment_text = &text[fragment.start_offset..fragment.stop_offset];
let highlighted = fragment.highlighted.iter().map(|item| {