id_effect 0.1.1

Effect<A, E, R> (sync + async), context/layers, pipe — interpreter-style, no bundled executor
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Ex 103 — `KeyedPool` reuses values per key under a global capacity cap.
use id_effect::{KeyedPool, Scope, run_async, succeed};

#[tokio::main(flavor = "current_thread")]
async fn main() {
  let pool = run_async(
    KeyedPool::make(2, |k: &'static str| succeed::<u32, (), ()>(k.len() as u32)),
    (),
  )
  .await
  .expect("pool");
  let scope = Scope::make();
  let v = run_async(pool.get("answer"), scope.clone())
    .await
    .expect("get");
  assert_eq!(v, 6);
  println!("103_pool ok");
}