Open jswrenn opened 4 years ago
Sounds awesome. It's similar to python itertools.islice function. But I'd like to use the normal array slicing syntax. After this we need a built-in way to match on iterators, and the basic needs are covered.
But I'd like to use the normal array slicing syntax.
The problem is that operator Index
only returns &Output
, and IndexMut
returns &mut Output
, so you can't create a new value for the indexing result.
An IndexableIter
trait seems like an interesting idea.
Itertools is considering a PR introducing iterator indexing, implemented in the same manner as the core library's slice indexing mechanism. This playground link demonstrates the gist of it:
I'm excited to merge this—it feels like something that ought to be in the standard library—but I want to avoid another
{Itertools,Iterator}::flatten
debacle; i.e., if the core library later adopts this same method, then itertools users calling this method will have builds break.Would this addition be a good fit for the core library?