From d15930630b2a01ffeb724efbee15258ecc23454c Mon Sep 17 00:00:00 2001 From: Ossama Hjaji Date: Wed, 11 Nov 2020 15:40:24 +0100 Subject: [PATCH] Update src/onefetch/repo.rs Co-authored-by: Spenser Black --- src/onefetch/repo.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/onefetch/repo.rs b/src/onefetch/repo.rs index c834566a3..902226121 100644 --- a/src/onefetch/repo.rs +++ b/src/onefetch/repo.rs @@ -71,20 +71,16 @@ impl Repo { .recurse_untracked_dirs(true), ))?; - let mut deleted: usize = 0; - let mut added: usize = 0; - let mut modified: usize = 0; - - for e in statuses.iter() { + let (added, deleted, modified) = statuses.iter().fold((0, 0, 0), |(added, deleted, modified), e| { let s: Status = e.status(); if s.is_index_new() || s.is_wt_new() { - added += 1; + (added + 1, deleted, modified) } else if s.is_index_deleted() || s.is_wt_deleted() { - deleted += 1; + (added, deleted + 1, modified) } else { - modified += 1; + (added, deleted, modified + 1) } - } + }); let mut result = String::new(); if modified > 0 {