Auto merge of #25047 - sinkuu:vec_intoiter_override, r=alexcrichton

Override methods `count`, `last`, and `nth` in vec::IntoIter.

#24214
This commit is contained in:
bors 2015-05-04 04:05:37 +00:00
commit 6517a0e90e
2 changed files with 10 additions and 0 deletions

View File

@ -1777,6 +1777,11 @@ fn size_hint(&self) -> (usize, Option<usize>) {
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")]

View File

@ -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(|| {