From 46decdb0ea60cc7c2e274b6bfaed180d1ecad0dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vignesh=20Sarma=20K=20=28=E0=B4=B5=E0=B4=BF=E0=B4=98?= =?UTF-8?q?=E0=B5=8D=E0=B4=A8=E0=B5=87=E0=B4=B7=E0=B5=8D=20=E0=B4=B6?= =?UTF-8?q?=E0=B5=AA=E0=B4=AE=20=E0=B4=95=E0=B5=86=29?= Date: Mon, 27 Aug 2018 22:16:47 +0530 Subject: [PATCH] compare against accumulator rather than init value --- src/snippet/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/snippet/mod.rs b/src/snippet/mod.rs index 4356e0a80..2429ac2e0 100644 --- a/src/snippet/mod.rs +++ b/src/snippet/mod.rs @@ -143,7 +143,7 @@ fn select_best_fragment_combination<'a>(fragments: Vec, 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| {