Function bicoro::bind

source · []
pub fn bind<'a, I, O, A, B, F>(
    m: Coroutine<'a, I, O, A>,
    f: F
) -> Coroutine<'a, I, O, B>where
    F: FnOnce(A) -> Coroutine<'a, I, O, B> + 'a,
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)));