macro_rules! concat {
    ($($s : expr), * $(,) ?) => { ... };
}
Expand description

Callbag factory that concatenates the data from multiple (2 or more) callbag sources.

It starts each source at a time: waits for the previous source to end before starting the next source.

Works with both pullable and listenable sources.

See https://github.com/staltz/callbag-concat/blob/db3ce91a831309057e165f344a87aa1615b4774e/readme.js#L29-L64

Examples

use crossbeam_queue::SegQueue;
use std::sync::Arc;

use callbag::{concat, for_each, from_iter};

let actual = Arc::new(SegQueue::new());

let source = concat!(from_iter(["10", "20", "30"]), from_iter(["a", "b"]));

for_each({
    let actual = Arc::clone(&actual);
    move |x| {
        println!("{}", x);
        actual.push(x);
    }
})(source);

assert_eq!(
    &{
        let mut v = vec![];
        for _i in 0..actual.len() {
            v.push(actual.pop().unwrap());
        }
        v
    }[..],
    ["10", "20", "30", "a", "b"]
);