diff options
| author | Scott McMurray <scottmcm@users.noreply.github.com> | 2017-11-04 22:52:45 -0700 |
|---|---|---|
| committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2017-11-04 22:52:45 -0700 |
| commit | b5dba91a19571f28e644a1aa5d60a10d3dd4562b (patch) | |
| tree | 0b4bb3ca67007057ddea681d61f805aa3765b5d0 | |
| parent | eef4d42a3f04519af885932de1826cbfebdeeb55 (diff) | |
| download | rust-b5dba91a19571f28e644a1aa5d60a10d3dd4562b.tar.gz rust-b5dba91a19571f28e644a1aa5d60a10d3dd4562b.zip | |
CR feedback
| -rw-r--r-- | src/libcore/iter/iterator.rs | 4 | ||||
| -rw-r--r-- | 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 @@ pub trait Iterator { /// #![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 @@ pub trait Iterator { /// ``` /// 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 @@ impl<A, B> Iterator for Chain<A, B> 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 @@ impl<A, B> DoubleEndedIterator for Chain<A, B> 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) } |
