Proposal for iter_index()
Nobody has claimed this yet.
- Dominant language
- Markdown
- Stars
- 6.6k
- Forks
- 1.7k
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Description
I want to discuss if the existence of an iterator that returns the index of the current state makes sense. I know the workaround with enumerate() that returns the value and the current index but the challenge with that is that you have to deal two values all the time instead of having a variable to the iterator with a method that returns the index whenever you need it.
I need it for a current project where I parse a file and need the current index to know which line is male formated. Because I have no known alternative than using enumerate I cannot reference to the iterator itself and use comfortable methods like peek() or next().
I would introduce a method that applies additional methods to the iterator like peekable() that gives you the command peek().
Maybe something like let it = list.iter().indexed() and you can execute let current_index = it.index()
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the proposed iter_index() or indexed() API and the issue's references to enumerate(), peek(), and peekable(). Determine whether the requested iterator behavior has a sufficiently defined scope and semantics; done would require a settled proposal rather than only discussion of possible method names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100