Giter Site home page Giter Site logo

Comments (7)

Philippe-Cholet avatar Philippe-Cholet commented on August 30, 2024 3

I see you have a clear understanding of it. I'm simply not understanding what it would look like, even what the Tracked<T,U,I> iterator would yield as items? U or (T, U)?

I'd like to know what code you can currently write (probably convoluted/messy) and what beautiful code you could write with Tracked.

from itertools.

jswrenn avatar jswrenn commented on August 30, 2024 1

If this is OK. I can start with the implementation straight away.

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:

I'd like to know what code you can currently write (probably convoluted/messy) and what beautiful code you could write with Tracked.

...is absolutely necessary.

Looking forward to playing around with this.

from itertools.

Philippe-Cholet avatar Philippe-Cholet commented on August 30, 2024

@advantageous-overtake I'm not sure I understand, could you elaborate with an usage example?

from itertools.

advantageous-overtake avatar advantageous-overtake commented on August 30, 2024

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.

from itertools.

advantageous-overtake avatar advantageous-overtake commented on August 30, 2024

Basically the adapter would encapsulate the original iterator and simply add a count field, and providing Deref and DerefMut implementations to maintain peeking functionality for types like Peekable<Enumerate<_>>.

from itertools.

advantageous-overtake avatar advantageous-overtake commented on August 30, 2024

If this is OK. I can start with the implementation straight away.

from itertools.

advantageous-overtake avatar advantageous-overtake commented on August 30, 2024

I see you have a clear understanding of it. I'm simply not understanding what it would look like, even what the Tracked<T,U,I> iterator would yield as items? U or (T, U)?

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 Pair would allow it to be used on any Iterator whose Item: Pair, followed by a blanket Pair implementation for all (T, U).

I'd rather go the Pair trait "way", as it allows for any type to be supported by Tracked and keeps generic bounds clean.

If any name collisions occur due to the trait's name, it could be renamed to Enumerated or alike.

So, in that case would be Tracked<I>.

from itertools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.