Open Ekleog opened 6 years ago
I, too, have run into a case where I needed this exact combinator. I think it was when trying to thread a BiLock
through a stream.
My gut feeling is that, if a stream becomes complex enough to require this behavior, it might be time to implement Stream
with a bespoke struct. I also think that the core stream/future combinators should be limited to those that have widely applicable use. I think there's room for an external crate to experiment with things like this -- streamtools/futuretools, dual to itertools.
So in the series “here is a stream adapter I wanted and thus wrote so do you want it?”, now comes the
FoldWithStream
stream adapter, that:So I'm thinking for this one there might be better ways to do it. However, the best I managed with “standard” stream adapters is the stuff I deleted in https://github.com/Ekleog/yuubind/commit/b6e0aff488b380a3df16ec1b664ec6432a5e7030 … because it stack overflow'd.
So here is what I have written, if you think it'd be useful that I PR it I can do so. :)