rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.35k stars 12.59k forks source link

Tracking Issue for `peek_index` #130711

Open x4exr opened 1 week ago

x4exr commented 1 week ago

Feature gate: #![feature(peek_index)]

This is a tracking issue for the new peek_index function on the Enumerate iterator.

Public API

let e = vec![1, 2, 3].into_iter().enumerate();
assert_eq!(e.peek_index(), 0);
e.next();
assert_eq!(e.peek_index(), 1);

Steps / History

Unresolved Questions

GrigorenkoPV commented 1 week ago

I suspect that the code example is slightly incorrect, as the .0 part after .peek_index() implies it returns a tuple.

Also I think a signature of the added function(s) would be a better fit than a usage example for the "Public API" section, (I'm not a team member though, so I might be wrong).

x4exr commented 1 week ago

That was a typo on my part lol, thanks for catching that