async-rs / async-std

Async version of the Rust standard library
https://async.rs
Apache License 2.0
3.96k stars 341 forks source link

Feature Request: fork/split/broadcast/unzip/switch a Stream into two #706

Open Earthson opened 4 years ago

Earthson commented 4 years ago

I was wandering if we could have a method to fork/split/broadcast/unzip/switch a Stream into two Streams. We do have a unzip now, but it returns two container, which is not symmetric to zip.

fn unzip() -> (LeftStream<L>, RightStream<R>) where Self: Stream<(L, R)>

fn switch(test: T => bool) -> (TrueStream<T>, FalseStream<T>)

related works: #543

https://docs.rs/broadcaster/1.0.0/broadcaster/

yoshuawuyts commented 4 years ago

Related: https://github.com/async-rs/async-std/issues/486