-
Notifications
You must be signed in to change notification settings - Fork 308
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
Feature request: Tracked adapter #957
Comments
@advantageous-overtake I'm not sure I understand, could you elaborate with an usage example? |
Sorry for the delayed answer. A possible use case would be getting the next byte to-be-yielded by an iterator, rather than having to use tricky ways such as peeking (given that it outputs index and value pairs) for the next index or having to query the length of the iterated buffer if the iterator has been exhausted. Thank you for your time. |
Basically the adapter would encapsulate the original iterator and simply add a count field, and providing |
If this is OK. I can start with the implementation straight away. |
I see you have a clear understanding of it. I'm simply not understanding what it would look like, even what the I'd like to know what code you can currently write (probably convoluted/messy) and what beautiful code you could write with |
Well, my first thought was that it should be only used on iterators yielding a 2-field tuple, but now I believe that introducing an additional trait going by the name I'd rather go the If any name collisions occur due to the trait's name, it could be renamed to So, in that case would be |
Before you make a PR, please sketch out a quick-and-dirty implementation in the Rust Playground so that we can get a better idea of what you're describing and can see the value it brings. What @Philippe-Cholet said:
...is absolutely necessary. Looking forward to playing around with this. |
In my code I have the need to get the most recent index without having to store it every time I advance the
CharIndices<'_>
iterator, so I propose the following:A generic implementation for all
Iterator<Item = (T, U)>
, with the adapter declared as:This allows generic integration with common adapters such as
Enumerate<_>
.The
Default
requirement forT
could also be dropped and have anOption
there if the current design is undesired.The text was updated successfully, but these errors were encountered: