diff options
author | David LeGare <legare@google.com> | 2022-03-02 16:21:08 +0000 |
---|---|---|
committer | David LeGare <legare@google.com> | 2022-03-02 16:21:08 +0000 |
commit | b72e905c595b81ee7ac7654f4fb3e0db460be21a (patch) | |
tree | 0ca62eb5d0beeab0cb7ee3c0db8111e81788c2cd /src/process_results_impl.rs | |
parent | 80f1e87637c04094d37a0f49ee09081b86525768 (diff) | |
download | itertools-b72e905c595b81ee7ac7654f4fb3e0db460be21a.tar.gz |
Update itertools to 0.10.3
Test: cd external/rust/crates && atest --host -c
Change-Id: Ic4635782fb45eaa4b94696aa8a7b3c5dc1910fc3
Diffstat (limited to 'src/process_results_impl.rs')
-rw-r--r-- | src/process_results_impl.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/process_results_impl.rs b/src/process_results_impl.rs index 9da108b..44308f3 100644 --- a/src/process_results_impl.rs +++ b/src/process_results_impl.rs @@ -30,6 +30,23 @@ impl<'a, I, T, E> Iterator for ProcessResults<'a, I, E> fn size_hint(&self) -> (usize, Option<usize>) { (0, self.iter.size_hint().1) } + + fn fold<B, F>(mut self, init: B, mut f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + let error = self.error; + self.iter + .try_fold(init, |acc, opt| match opt { + Ok(x) => Ok(f(acc, x)), + Err(e) => { + *error = Err(e); + Err(acc) + } + }) + .unwrap_or_else(|e| e) + } } /// “Lift” a function of the values of an iterator so that it can process |