Function bicoro::executor::run_until_output
source · [−]pub fn run_until_output<'a, Iter, Input, Output, Result>(
routine: Coroutine<'a, Input, Output, Result>,
events: Iter
) -> IteratorExecutorResult<'a, Iter, Input, Output, Result>where
Iter: Iterator<Item = Input>,
Expand description
Consumes a coroutine and runs it with the iterated events This may run to completion, or may consume all the inputs Returns whenever an output is produced, and returns the remaining iterator and coroutine so it can be called again
use bicoro::*;
use bicoro::executor::*;
// sample coroutine
let co : Coroutine<i32,i32,()> = receive().and_then(|i| send(i));
// inputs to send
let inputs = vec![1];
let exec = run_until_output(co,inputs.into_iter());
assert!(matches!(exec, IteratorExecutorResult::Output{ output: 1,..}));