id_effect 0.10.1

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
//! Ex 103 — A `KeyedPool` reuses values per key; a checked-out value returns when its scope closes.
use id_effect::{Effect, KeyedPool, Scope, succeed};

fn main() {
  let pool = KeyedPool::new(2, |k: &'static str| succeed(k.len() as u32));
  let scope = Scope::new();
  let v: Effect<u32, id_effect::Never> = pool.get("answer", &scope);
  assert_eq!(v.block_on().into_result().ok(), Some(6));
  println!("103_pool ok");
}