smol-rs / futures-lite

Futures, streams, and async I/O combinators.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add `dedupe()` to `StreamExt`

jquesada2016 opened this issue · comments

I am surprised this is something not currently implemented for Stream, unless I am missing something. It would be a great addition.

It is not surprising that methods that do not exist in Iterator are not implemented in StreamExt.
https://doc.rust-lang.org/nightly/std/index.html?search=dedupe

Also, please describe the specific behavior you need. dedupe has at least two patterns (contiguous elements vs all elements).

In the context of streams, the method which I believe makes most sense is deduping sequential elements, not all elements, as this is an operation more suited for doing in a collection. However, deduping sequential elements can be very handy for implementing signal-type interfaces that are only triggered when an element actually changes.

I understand thinking of streams as just the future equivalent of future-backed iterators (because that seems to be the design intent), however, I think they can be slightly more, mainly, well, streams of data that can be altered, filtered, diverted, etc., in ways an iterator might not be.

At least that's my opinion.