pub fn bind<'a, I: 'a, O: 'a, RA: 'a, RB, F: 'a>(
m: Coroutine<'a, I, O, RA>,
f: F
) -> Coroutine<'a, I, O, RB> where
F: FnOnce(RA) -> Coroutine<'a, I, O, RB> + Send + Sync,
Expand description
Chain outputs together.
This allows the results from one item to flow into the next one. This can call any arbitrary co-routine The next routine needs the same inputs and outputs, but can change it’s result This is equivalent to and_then for the Future type.
use bicoro::*;
// reads two input values and adds them.
let co:Coroutine<i32,(),i32> = bind(receive(),|a:i32| bind(receive(), move |b:i32| result(a+b)));