3 releases

0.1.2 Mar 1, 2022
0.1.1 Feb 28, 2022
0.1.0 Feb 24, 2022

#719 in Asynchronous

Download history 2873/week @ 2024-07-20 3231/week @ 2024-07-27 1833/week @ 2024-08-03 1637/week @ 2024-08-10 2407/week @ 2024-08-17 1140/week @ 2024-08-24 1467/week @ 2024-08-31 1164/week @ 2024-09-07 1517/week @ 2024-09-14 1608/week @ 2024-09-21 1817/week @ 2024-09-28 1762/week @ 2024-10-05 3122/week @ 2024-10-12 3090/week @ 2024-10-19 2859/week @ 2024-10-26 2636/week @ 2024-11-02

11,905 downloads per month
Used in 6 crates (4 directly)

MIT/Apache

25KB
478 lines

merge-streams

Merge multiple streams into one.

Based on Yoshua Wuyts's futures-concurrency crate and the corresponding Futures Concurrency III post. Since the futures-concurrency crate now supports stable Rust too, there is no reason to this crate instead anymore.

Example

Merge multiple streams to handle values as soon as they're ready, without ever dropping a single value:

use merge_streams::MergeStreams;
use futures_lite::future::block_on;
use futures_lite::{stream, StreamExt};
fn main() {
    block_on(async {
        let a = stream::once(1);
        let b = stream::once(2);
        let c = stream::once(3);
        let mut s = (a, b, c).merge();
        let mut counter = 0;
        s.for_each(|n| counter += n).await;
        assert_eq!(counter, 6);
    })
}

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0.3–0.8MB
~18K SLoC