about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-05-04 04:05:37 +0000
committerbors <bors@rust-lang.org>2015-05-04 04:05:37 +0000
commit6517a0e90ef607227eec3e888707c36bf191fd09 (patch)
tree3675a310f3790844a9cfaa413ba7f1ae6ae21415 /src
parent45b9a34a7b0ad3ccf85cd8f5a92cfe2e01861e69 (diff)
parent5d8431c20387531d7dcbb6ad3841d15fe41b3c09 (diff)
downloadrust-6517a0e90ef607227eec3e888707c36bf191fd09.tar.gz
rust-6517a0e90ef607227eec3e888707c36bf191fd09.zip
Auto merge of #25047 - sinkuu:vec_intoiter_override, r=alexcrichton
Override methods `count`, `last`, and `nth` in vec::IntoIter.

#24214
Diffstat (limited to 'src')
-rw-r--r--src/libcollections/vec.rs5
-rw-r--r--src/libcollectionstest/vec.rs5
2 files changed, 10 insertions, 0 deletions
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs
index 33de6b79736..935648099a7 100644
--- a/src/libcollections/vec.rs
+++ b/src/libcollections/vec.rs
@@ -1777,6 +1777,11 @@ impl<T> Iterator for IntoIter<T> {
         let exact = diff / (if size == 0 {1} else {size});
         (exact, Some(exact))
     }
+
+    #[inline]
+    fn count(self) -> usize {
+        self.size_hint().0
+    }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
diff --git a/src/libcollectionstest/vec.rs b/src/libcollectionstest/vec.rs
index 8a8da0d9faa..ac9cf198d67 100644
--- a/src/libcollectionstest/vec.rs
+++ b/src/libcollectionstest/vec.rs
@@ -542,6 +542,11 @@ fn test_split_off() {
     assert_eq!(vec2, [5, 6]);
 }
 
+#[test]
+fn test_into_iter_count() {
+    assert_eq!(vec![1, 2, 3].into_iter().count(), 3);
+}
+
 #[bench]
 fn bench_new(b: &mut Bencher) {
     b.iter(|| {