-
Notifications
You must be signed in to change notification settings - Fork 676
Description
I'm working on a project that uses streams heavily, and one thing that comes up a lot a few times is consuming streams up to a certain limit (typically the total bytesize of items buffered so far). Originally I thought that StreamExt::take_while looked right, but it's exclusive, so it consumes one more item from the source stream than it ever yields (which absolutely makes sense given its definition and implementation). Because the user's predicate is called after an item has been consumed, I don't believe there's any way to build this on top of StreamExt::take_while.
I'm using rust-rdkafka's StreamConsumer in my actual project, in which consuming from the source stream has side-effects, which is why it's key that I not drop items after consuming them.
For now, I've just implemented this myself but it might be nice to have in StreamExt.
See a very similar upstream issue on Iterator at rust-lang/rust#62208