id_effect 0.9.0

Effect<A, E, R>: lazy Send effects over a typed capability list, run on a fiber runtime (Tokio executor), with layers, streams, schedules and coordination
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! Ex 100 — A duplex `Channel` backed by a `Queue` (write / read outside a `Stream`).
use id_effect::{Channel, Effect};

fn main() {
  let ch = Channel::<i32>::duplex_unbounded();
  let program: Effect<i32, ()> = ch
    .write(21)
    .then(ch.write(21))
    .then(ch.read())
    .zip(ch.read())
    .map(|(a, b)| a.expect("elem") + b.expect("elem"));
  assert_eq!(program.block_on().into_result().ok(), Some(42));
  println!("100_channel_queue ok");
}