提交 6517a0e9 编写于 作者: B bors

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

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

#24214
......@@ -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")]
......
......@@ -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(|| {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册