From b5dba91a19571f28e644a1aa5d60a10d3dd4562b Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sat, 4 Nov 2017 22:52:45 -0700 Subject: [PATCH] CR feedback --- src/libcore/iter/iterator.rs | 4 ++-- src/libcore/iter/mod.rs | 14 ++++---------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index 8dbb3a98bee..6a4dba31b62 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -1372,7 +1372,7 @@ fn partition(self, mut f: F) -> (B, B) where /// #![feature(iterator_try_fold)] /// let a = [1, 2, 3]; /// - /// // the checked sum of all of the elements of a + /// // the checked sum of all of the elements of the array /// let sum = a.iter() /// .try_fold(0i8, |acc, &x| acc.checked_add(x)); /// @@ -1431,7 +1431,7 @@ fn try_fold(&mut self, init: B, mut f: F) -> R where /// ``` /// let a = [1, 2, 3]; /// - /// // the sum of all of the elements of a + /// // the sum of all of the elements of the array /// let sum = a.iter() /// .fold(0, |acc, &x| acc + x); /// diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index ff0f46a7b13..e173f43b5e6 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -786,11 +786,8 @@ fn try_fold(&mut self, init: Acc, mut f: F) -> R where } _ => { } } - match self.state { - ChainState::Both | ChainState::Back => { - accum = self.b.try_fold(accum, &mut f)?; - } - _ => { } + if let ChainState::Back = self.state { + accum = self.b.try_fold(accum, &mut f)?; } Try::from_ok(accum) } @@ -917,11 +914,8 @@ fn try_rfold(&mut self, init: Acc, mut f: F) -> R where } _ => { } } - match self.state { - ChainState::Both | ChainState::Front => { - accum = self.a.try_rfold(accum, &mut f)?; - } - _ => { } + if let ChainState::Front = self.state { + accum = self.a.try_rfold(accum, &mut f)?; } Try::from_ok(accum) } -- 2.44.0