I've been writing async code recently and I'm a bit puzzled by the design of futures::stream::StreamExt.
Most of the functions on this trait require asynchronous callbacks, e.g.
map doesn't: it takes a synchronous callback... but it does have an async equivalent
I often don't need the async version of
filter_map. It's not a big deal to work around; I could either use an async block or
std::future::ready, but it's mentally complex to remember which is which.
Is there a way and would it be a good idea to make these functions generic over both a sync and an async closure so that I don't have to think about this? If not, wouldn't it make sense to have two parallel sets of functions? for instance:
take_while - synchronous closure
then_take_while - closure returning a Future