about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorPalmer Cox <p@lmercox.com>2013-12-11 20:51:22 -0500
committer“Palmer <pcox@intelligent.net>2013-12-20 20:40:16 -0500
commit2c539d4eecec3c63f878a3798e0ea4df79b46f19 (patch)
tree2142e50e6cc40f15c51305ec2bd77ca01023e1ec /src/libstd
parentefd619467df28b48b97250b2857b18a032b5dab6 (diff)
downloadrust-2c539d4eecec3c63f878a3798e0ea4df79b46f19.tar.gz
rust-2c539d4eecec3c63f878a3798e0ea4df79b46f19.zip
Update next() and size_hint() for MutSpliterIterator
Update the next() method to just return self.v in the case that we've reached
the last element that the iterator will yield. This produces equivalent
behavior as before, but without the cost of updating the field.

Update the size_hint() method to return a better hint now that #9629 is fixed.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/vec.rs19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs
index 17e961723cf..b03cef09350 100644
--- a/src/libstd/vec.rs
+++ b/src/libstd/vec.rs
@@ -2528,13 +2528,13 @@ impl<'a, T> Iterator<&'a mut [T]> for MutSplitIterator<'a, T> {
 
     #[inline]
     fn size_hint(&self) -> (uint, Option<uint>) {
-        if self.finished { return (0, Some(0)) }
-
-        // if the predicate doesn't match anything, we yield one slice
-        // if it matches every element, we yield len+1 empty slices.
-        // FIXME #9629
-        //(1, Some(self.v.len() + 1))
-        (1, None)
+        if self.finished {
+            (0, Some(0))
+        } else {
+            // if the predicate doesn't match anything, we yield one slice
+            // if it matches every element, we yield len+1 empty slices.
+            (1, Some(self.v.len() + 1))
+        }
     }
 }
 
@@ -2547,10 +2547,7 @@ impl<'a, T> DoubleEndedIterator<&'a mut [T]> for MutSplitIterator<'a, T> {
             None => {
                 self.finished = true;
                 let tmp = util::replace(&mut self.v, &mut []);
-                let len = tmp.len();
-                let (head, tail) = tmp.mut_split_at(len);
-                self.v = tail;
-                Some(head)
+                Some(tmp)
             }
             Some(idx) => {
                 let tmp = util::replace(&mut self.v, &mut []);