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:
commit
6517a0e90e
@ -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(|| {
|
||||
|
Loading…
Reference in New Issue
Block a user