Skip to content

add next_index to Enumerate #139533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 20, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
added test for Enumerate::next_index on empty iterator
  • Loading branch information
jogru0 committed Apr 19, 2025
commit f121c7c3605d195a05a9802735994e3576be9d62
10 changes: 10 additions & 0 deletions library/coretests/tests/iter/adapters/enumerate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,13 @@ fn test_double_ended_enumerate() {
assert_eq!(it.next_back(), Some((2, 3)));
assert_eq!(it.next(), None);
}

#[test]
fn test_empty_iterator_enumerate_next_index() {
let mut it = empty::<i32>().enumerate();
assert_eq!(it.next_index(), 0);
assert_eq!(it.next_index(), 0);
assert_eq!(it.next(), None);
assert_eq!(it.next_index(), 0);
assert_eq!(it.next_index(), 0);
}
1 change: 1 addition & 0 deletions library/coretests/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#![feature(maybe_uninit_write_slice)]
#![feature(min_specialization)]
#![feature(never_type)]
#![feature(next_index)]
#![feature(numfmt)]
#![feature(pattern)]
#![feature(pointer_is_aligned_to)]
Expand Down
Loading