about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libcore/iter/iterator.rs4
-rw-r--r--src/libcore/iter/mod.rs14
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)
     }